Adding comm.jar to my jar

I add the comm.jar library to my .jar and I get javax.comm.NoSuchPortException .

Is this error because I am not adding javax.comm.properties and win32com.dll to my jar? How to add this file inside the manifest?

+4
source share
4 answers

Java does not support Jars inside Jars. The proper way to ensure that javax.comm packages are in the path of the application execution class is to add a manifest that provides a relative path to the dependent Jar, and make sure the Jar is in the right place. For more information, see Working with manifest files: the basics, and especially Adding classes to the JAR File Pathpath in a Java tutorial.

There are other methods that you can use for applets and applications. launched using Java Web Start.

+3
source

@Gogoo responds to copy material to the JVM installation directory.

It should work, but as a rule, this is not a good idea:

  • Everything that you install in this way will be used by all the applications that you use with this installation. Depending on what it is, it may interfere with other applications.

  • Each time you upgrade the JVM, you must remember to copy these files to the new installation directory.

IMO, it is best to put these files in a separate directory tree and write a shell script to launch the application with the files on the class path and the library path. And / or see @Andrew Thompson answer.

+2
source

Try FatJar .

The Fat Jar Eclipse plugin is a deployment tool that deploys the Eclipse java-project into a single executable jar.

He adds the "Build Fat-JAR" entry to the Export-Wizard. In addition to the jcl-exporter standards associated with the eclipse standard, it is included in the "Fat-Jar", so the jar received contains all the necessary classes and can be executed directly using "java-jar", there is no path to the classes to be set, no additional banks should not be deployed.

+1
source

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

and run your.jar command line:

java -jar your.jar

0
source

All Articles