Adding comm.jar into my jar

蹲街弑〆低调 提交于 2019-12-05 12:33:14

Java does not support Jars within Jars. The correct way to ensure the javax.comm packages are on the run-time class-path of the application is to add a manifest that provides a relative path to the dependent Jar, and ensure that Jar is in the right place to be found. For details see Working with Manifest Files: The Basics & particularly Adding Classes to the JAR File's Classpath in the Java Tutorial.

There are other methods that can be used for applets and apps. launched using Java Web Start.

@Gogoo's answer says to copy stuff into your JVM installation directory.

It should work, but it is generally not a good idea:

  • The stuff that you install that way will be shared by all applications that you run using that installation. Depending on the what it is, it may interfere with other applications.

  • Each time you update your JVM, you have to remember to copy those files into the new installation directory.

IMO, a better idea is to put those files in a separate directory tree, and write a wrapper script to launch your application with the files on the classpath and library path. And/or see @Andrew Thompson's answer.

Try FatJar.

The Fat Jar Eclipse Plug-In is a Deployment-Tool which deploys an Eclipse java-project into one executable jar.

It adds the Entry "Build Fat-JAR" to the Export-Wizard. In addition to the eclipse standard jar-exporter referenced classes and jars are included to the "Fat-Jar", so the resulting jar contains all needed classes and can be executed directly with "java -jar", no classpath has to be set, no additional jars have to be deployed.

copy comm.jar \jdk1.6\jre\lib\ext
copy win32com.dll \jdk1.6\bin
copy javax.comm.properties \jdk1.6\jre\lib

and start your.jar over command line:

java -jar your.jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!