0

I am using some classes from javafx library (these are observable collections). I can't include jfxrt.jar into my distribution, since it is java version dependent and I don't know which java my program will run on.

How to accomplish?

UPDATE

I put jfxrt.jar in lib subdirectory of the programm directory and the following command does not work

java -classpath ./lib/jfxrt.jar -jar MyProgram.jar 

Why?

UPDATE 2

This was also does not work

java -cp MyProgram.jar;./lib/* MyClass
Dims
  • 47,675
  • 117
  • 331
  • 600
  • Actually **you can** include jfxrt.jar. It will run on most machines (especially if you are just using a few classes as mentioned). Plus you can always go to native packaging. – Mansueli Jun 19 '14 at 21:56
  • JRE distribution has multiple jars inside. How are they used without reference, for example: alt-rt.jar charsets.jar deploy.jar javaws.jar jce.jar jfr.jar jfxrt.jar jsse.jar management-agent.jar plugin.jar resources.jar rt.jar – Dims Jun 19 '14 at 22:00
  • I included the jfxrt from java 8 into a windows xp with java 7 and it ran just fine. And again, if you are afraid **use native packaging**. – Mansueli Jun 19 '14 at 22:03
  • What is native packaging, sorry? – Dims Jun 19 '14 at 22:03
  • 1
    Look [here](https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx). Native packaging includes a full JRE to run in any operating system and with system binaries. – Mansueli Jun 19 '14 at 22:05
  • Wow, it's hot! Would like to try other ways first. – Dims Jun 19 '14 at 22:15
  • Note the [Java launcher documentation](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html): "When you use the `-jar` option, the specified JAR file is the source of all user classes, and other class path settings are ignored." – jewelsea Jun 20 '14 at 00:12

1 Answers1

0

In your jar META-INF folder create a MANIFEST.MF file with this contents:

Manifest-Version: 1.0
Class-Path: . /lib/jfxrt.jar
Main-Class: package.MyClass

or put this in .classpath the root of the jar:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="lib" path="/lib/jfxrt.jar"/>
</classpath>

Then try to launch it again

Mansueli
  • 6,223
  • 8
  • 33
  • 57