java - how to create JAR File -
i know creating jar files easy, utilize eclipse, right click on project , select export , follow wizard.
there way command-line, can utilize command.
jar cf myjarfilename.jar file1.class file2.class the problem cannot utilize use eclipse create jar because code compiled in separate projects , place .class files in particular hierarchy, compiled 'em jar , place 'em @ specific location web-app uses it.
i utilize command line not practical hierarchy complex , uses lot of .class files. (folders , .class files)
now need create jar out of it. how to.
yes, making .jar file easy.
there many alternatives.
1) eclipse: select project > right-click, export as, .jar
2) .bat file/shell script:
jar cf myjarfilename.jar file1.class file2.class 3) .bat file/shell script:
mkdir staging-directory copy/s source-files staging-directory jar cf myjarfilename.jar staging-directory 4) write ant build.xml or maven pom.xml automate build (including generating .jar file).
here's tutorial on apache ant/build.xml:
http://www.vogella.com/tutorials/apacheant/article.html
<!--creates deployable jar file --> <target name="jar" depends="compile"> <jar destfile="${dist.dir}\de.vogella.build.test.ant.jar" basedir="${build.dir}"> <manifest> <attribute name="main-class" value="test.main" /> </manifest> </jar> </target> java eclipse jar
No comments:
Post a Comment