简体   繁体   中英

Manifest Classpath for Jar files

I created a small application which includes an external package called JavaFX. The package contains 4 jar file. When I create a jar from the command line to the current directory, the jar executes OK (importing classes from the 4 jars). But when I move that jar file from a different directory, the file wont execute. In other words the created jar can't seem to locate the classes in those jar files (JavaFX jars) ?

Below is the manifest file:

Main-Class: QuizMenu    
Class-Path:
 deploy.jar
 javaws.jar
 jfxrt.jar
 plugin.jar

The textfile does contain a space at the start and end of each line of the jars, and a final carriage return at the last line (Each line apart from the last line does not contain a carriage return). Also the Main-Class: header works OK. (Just the classpath doesn't seem to work).

Can anyone identify the problem with the file?

Recommendation

You should not refer to any of these ( deploy.jar javaws.jar jfxrt.jar plugin.jar ) jar files in your mainifest file.


JavaFX Packaging Tools

Instead, you should use JavaFX aware deployment tools such as:

  1. javafxpackager
  2. JavaFX ant tasks
  3. JavaFX maven plugin
  4. JavaFX gradle plugin
  5. NetBeans JavaFX project
  6. Some other compatible tool which might come along in the future.

The above tools will appropriately package your application to use JavaFX.


Background

If you try to bundle the JavaFX, Java deployment and Java plugin jar files with your application, then when you run your application on a different Java version (such as Java 8 or 9), it may not function correctly as JavaFX in all future releases will be defined to be part of the Java runtime platform and not as a separately installed library or a library which can be bundled with an application separate from the rest of the Java runtime.

Additionally, jar files such a jfxrt.jar rely on numerous native dynamically linked libraries (.so, .dll, etc) which differ from platform to platform and have 32 bit and 64 bit variants. The version of jfxrt.jar must match the version of the underlying native libraries (and the underlying native libraries for the appropriate platform must be available to the dynamic load linker) in order for jfxrt.jar (eg JavaFX) to function correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM