mombas.blogg.se

Compiling java into jar
Compiling java into jar






compiling java into jar

jar file in the target directory we can take a look at what is inside: $ jar tvf target/ 0 Fri Jan 03 16:10: META-INF/ 133 Fri Jan 03 16:10: META-INF/MANIFEST.MF 0 Fri Jan 03 16:10: localdomain/ 0 Fri Jan 03 16:10: localdomain/localhost/ 0 Fri Jan 03 16:10: localdomain/localhost/tutorial/ 577 Fri Jan 03 16:10: localdomain/localhost/tutorial/Main.class 0 Fri Jan 03 16:10: META-INF/maven/ 0 Fri Jan 03 16:10: META-INF/maven// 0 Fri Jan 03 16:10: META-INF/maven//java-archive/ 180 Fri Jan 03 16:10: META-INF/maven//java-archive/pom.xml 134 Fri Jan 03 16:10: META-INF/maven//java-archive/pom.propertiesĪnd we can run the code from the. maven-jar-plugin:2.4:jar (default-jar) java-archive - Building jar: target/ - BUILD SUCCESS - Total time: 1.923s Finished at: Fri Jan 03 16:10: Final Memory: 12M/156M -īy convention Maven puts the. build is platform dependent! skip non existing resourceDirectory src/test/resources - maven-compiler-plugin:2.5.1:testCompile (default-testCompile) java-archive - No sources to compile - maven-surefire-plugin:2.12.4:test (default-test) java-archive - No tests to run.

compiling java into jar

build is platform dependent! Compiling 1 source file to target/classes - maven-resources-plugin:2.6:testResources (default-testResources) java-archive - Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! skip non existing resourceDirectory src/main/resources - maven-compiler-plugin:2.5.1:compile (default-compile) java-archive - File encoding has not been set, using platform encoding UTF-8, i.e.

compiling java into jar

Building java-archive 1.0-SNAPSHOT - maven-resources-plugin:2.6:resources (default-resources) java-archive - Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. jar file for us $ mvn package Scanning for projects. jar file straight away, we can create a simple Java file, src/main/java/localdomain/localhost/tutorial/Main.java: package public class Main Īnd then we can ask Maven to package up the. So we can use these defaults to get building our. jar file will be found in the src/main/resources directory jar file will be found in the directory src/main/java and any additional resources that should be copied into the. There are similar conventions that Maven uses, for example Maven expects that the Java source code to be compiled and packaged within the. jar file, we don't have to tell Maven what packaging to use. Maven uses convention over configuration, this means that you only need to tell Maven the things that are different from the defaults.įor example, the default packaging is jar, so conveniently for us here, as we want to build a. We save the project model in a file called pom.xml Convention over configuration This gives us the following project model 4.0.0 java-archive 1.0-SNAPSHOT jar file for local consumption only, so we will use the coordinates

  • the version - this is to distinguish different versions of the same artifact.īefore we can create a project model, we need to decide what the coordinates of the artifacts produced by the project model will be.
  • the artifact identifier - this is to identify artifacts within the group.
  • the group identifier - this is usually a DNS name in reverse order.
  • Maven likes to give things coordinates to help locate them.

    compiling java into jar

    This is a continuation of the Maven in 60 seconds tutorial Project model








    Compiling java into jar