开发者

Making J2EE application as JAR or any executable

HI, I have a J2EE applicati开发者_Python百科on with some .jsp as start page. Is there a way that I can make my project an executable through eclipse or other means?

Thanks!


Usually people use build scripts to package their application into a JAR. Such as ANT and Maven.

  1. Using Maven is the easiest approach all you do is create your pom.xml file and create your executions. Then you just run the commands below which will technically package it into a single executable jar:

    mvn install
    mvn package
    
  2. Or you can use Ant using the jar task. http://ant.apache.org/manual/Tasks/jar.html

  3. If you would like to do it within Eclipse, you can right click on your project and choose, "Export" and select Jar.

  4. You can do it Manually as well. Just make sure you have a manifest.mf file that contains a Main-Class section:

    Manifest-Version: 1.0
    Main-Class: FooClass
    Class-path: .
    

    Then you can jar it make it executable by doing:

    jar cvfm foo.jar manifest.mf FooClass.class
    

I personally would like to use a build script, using something like Maven makes the process painless easier to maintain in the future.


Note

You could use One-JAR which lets you package a Java application together with its dependency Jars into a single executable Jar file. It integrates really well with Maven and Ant. A good tutorial could be found here: http://www.asjava.com/core-java/making-an-executable-jar-file/


0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜