Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (781)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (857)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Issues with Java11/JavaFX11 modules  (Read 347 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid
« Posted 2019-02-10 19:30:03 »

Hey guys, I posted an issue on StackOverflow yesterday and haven't be able to get any substantial help on it. I figured I'd post the problem here and see if I could get any help from you guys:

https://stackoverflow.com/questions/54609825/java11-javafx11-module-deployment-mess-runnable-jar-that-works-if-clicked-but

Sorry in advance if there's some kind of obvious answer to the problem, I'm just genuinely new to Java11. Personally I think the whole moduling thing is overcomplicated for no real good reason but that's just me. If you guys could upvote the question I'd also appreciate that so more people will take a look at the question.

it just werks
Offline philfrei
« Reply #1 - Posted 2019-02-11 01:26:08 »

There is a lot being asked in your stackoverflow question. It's not the easiest thing for me to untangle. But I thought I could maybe put in a couple helpful points.

If your program has javafx, the command
1  
java -jar yourprogram.jar
won't work. You have to include a path to the JavaFX modules.

OpenJDX.io has a good tutorial. This page (subpage: Runtime Images/Modular with CLI) has the syntax.

One thing that threw me at first when I started using OpenJDK 11 with OpenJFX 11, is that the code needs to be able to reach both the javafx.jar files and the javafx modules. Thus, you have to install BOTH the JDK and the jmods from Gluon's JavaFX download page.

With Eclipse, to develop and be able to run a program with JavaFX, I had to include the SDK files in the  Build Path/Libraries/Modulepath. (It is sitting adjacent to the JRE System Library -- now OpenJDK 11.)

Also, I have to have the following in Run Configurations/Arguments/VM arguments:

    --module-path "c:\Program Files\Java\javafx-jmods-11.0.1" --add-modules=javafx.controls

This is covered in the openjdk.io "Getting Started" tutorial subsection on Eclipse.

I have never used "Export/Java/Runnable JAR file" but have always used "Export/Java/JAR file", so I can't help with that.

In fact, at this point, I just export source code and do command-line compiling and jlinking, along a slightly modified version of this tutorial. For Windows, I use InnoSetup5 for the last stage of packaging.

For the Mac, I'm still working out the details of packaging. I got JLINK to work and can run applications on the Mac, but am still trying to get my brain around the steps where one turns the file folder into an .app. I posted earlier today on StackOverflow asking for some help to connect the dots on this.

music and music apps: http://adonax.com
Offline SkyAphid
« Reply #2 - Posted 2019-02-11 06:45:22 »

There is a lot being asked in your stackoverflow question. It's not the easiest thing for me to untangle. But I thought I could maybe put in a couple helpful points.

If your program has javafx, the command
1  
java -jar yourprogram.jar
won't work. You have to include a path to the JavaFX modules.

OpenJDX.io has a good tutorial. This page (subpage: Runtime Images/Modular with CLI) has the syntax.

One thing that threw me at first when I started using OpenJDK 11 with OpenJFX 11, is that the code needs to be able to reach both the javafx.jar files and the javafx modules. Thus, you have to install BOTH the JDK and the jmods from Gluon's JavaFX download page.

With Eclipse, to develop and be able to run a program with JavaFX, I had to include the SDK files in the  Build Path/Libraries/Modulepath. (It is sitting adjacent to the JRE System Library -- now OpenJDK 11.)

Also, I have to have the following in Run Configurations/Arguments/VM arguments:

    --module-path "c:\Program Files\Java\javafx-jmods-11.0.1" --add-modules=javafx.controls

This is covered in the openjdk.io "Getting Started" tutorial subsection on Eclipse.

I have never used "Export/Java/Runnable JAR file" but have always used "Export/Java/JAR file", so I can't help with that.

In fact, at this point, I just export source code and do command-line compiling and jlinking, along a slightly modified version of this tutorial. For Windows, I use InnoSetup5 for the last stage of packaging.

For the Mac, I'm still working out the details of packaging. I got JLINK to work and can run applications on the Mac, but am still trying to get my brain around the steps where one turns the file folder into an .app. I posted earlier today on StackOverflow asking for some help to connect the dots on this.


That command actually DOES work if you use it just like that since it's a runnable jar. You can also run the jar by just clicking it. The problem is when you try and use the java command from a specific JRE path for some reason.

As for the module path, I've tried that, but it only appears to work if you give it an explicit path. That's not so easy to do if you're running the software on someone elses computer. You'd also have to expect them to have installed it in the same place as you. (Unless you mean setting this up before exporting the JAR - I already do this in Eclipse to make the Runnable JAR, so that's not an issue here. The issue is that despite this, Java is saying I didn't include JavaFX when I try and run the program in my own way).

Regardless, I'll check out those resources and let people know if I can get it working.

Edit: I reformatted the Stack question to make it easier to read.

Edit 2: The reason why the default jar command was working for me was because my computer was defaulting to Java10. Going to keep looking into the issue.

it just werks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2019-02-11 21:31:05 »

Quote
As for the module path, I've tried that, but it only appears to work if you give it an explicit path. That's not so easy to do if you're running the software on someone elses computer. You'd also have to expect them to have installed it in the same place as you.

Yes. I kind of gave up hope of realistically being able to distribute Java programs using JavaFX by the old method of distributing a jar, for exactly the reasons you list. Maybe it will be possible to run executable jars if only Swing is used, going forward. But I'm not counting on that, either, especially if there are new complications, like the user having to figure out where to load Java from if Oracle is going to start charging a fee for Java.

That's why I'm trying to solve for customized, self-contained apps. The Win64 task list is pretty easy, now that I have the command-line commands stored for easy copy/paste into the shell. Can build a distributable in about 3 or 4 minutes, using less than a half-dozen commands. I'm still working on getting the Mac jlink file folder build configured as an .app. This post gives me hope that it won't require dealing with Bundles and Info.plist files to do so. Looking forward to some free time later this week to give it a try.

music and music apps: http://adonax.com
Offline gouessej
« Reply #4 - Posted 2019-02-12 00:03:14 »

but am still trying to get my brain around the steps where one turns the file folder into an .app
Maybe it helps, it needs some small changes to work as is with Java 11:
http://tuer.sourceforge.net/en/documentation/#create-os-x-app-bundle
https://svn.code.sf.net/p/tuer/code/pre_beta/src/main/xml/jndt/antlib.xml

Julien Gouesse | Personal blog | Website | Jogamp
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (1177 views)
2018-11-16 13:46:03

hadezbladez (531 views)
2018-11-16 13:41:33

hadezbladez (1190 views)
2018-11-16 13:35:35

hadezbladez (274 views)
2018-11-16 13:32:03

EgonOlsen (2571 views)
2018-06-10 19:43:48

EgonOlsen (2790 views)
2018-06-10 19:43:44

EgonOlsen (1566 views)
2018-06-10 19:43:20

DesertCoockie (2271 views)
2018-05-13 18:23:11

nelsongames (2123 views)
2018-04-24 18:15:36

nelsongames (2817 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!