Discussion:
Why cannot run compiled JavaFX 11 class?
Murray Eisenberg
2018-10-30 21:05:46 UTC
Permalink
This is under macOS Mojave (10.14).

Following instructions at https://openjfx.io/openjfx-docs/#install-javafx, I compiled the sample HelloFX.java via:

javac --module-path $PATH_TO_FX --add-modules=javafx.controls /Users/me/Documents/java/HelloFX.java

But now if I attempt to run that...

java --module-path $PATH_TO_FX --add-modules=javafx.controls /Users/me/Documents/java/HelloFX

... I get error:

Error: Could not find or load main class .Users.me.Documents.java.HelloFX
Caused by: java.lang.ClassNotFoundException: /Users/me/Documents/java/HelloFX

Yet the file reported as not found is there:

ls -l /Users/me/Documents/java/HelloFX.class
-rwxr--r-- 1 me staff 1336 Oct 30 16:01 /Users/murray/Documents/java/HelloFX.class

(I had already changed permissions to add `u+x` in case that was the issue, but apparently that was not the trouble.

What's wrong?

(Yes, `$PATH_TO_FX` does point to `javafx-sdk-11/lib`.)

——
Murray Eisenberg ***@math.umass.edu
Mathematics & Statistics Dept.
University of Massachusetts Amherst
Steve Hannah
2018-10-30 21:17:59 UTC
Permalink
The "java" command expects a fully-qualified class name, not a file path as
its argument.

E.g.
cd /Users/me/Documents/java
java --module-path $PATH_TO_FX --add-modules=javafx.controls HelloFX
Post by Murray Eisenberg
This is under macOS Mojave (10.14).
Following instructions at https://openjfx.io/openjfx-docs/#install-javafx,
javac --module-path $PATH_TO_FX --add-modules=javafx.controls
/Users/me/Documents/java/HelloFX.java
But now if I attempt to run that...
java --module-path $PATH_TO_FX --add-modules=javafx.controls
/Users/me/Documents/java/HelloFX
Error: Could not find or load main class
.Users.me.Documents.java.HelloFX
/Users/me/Documents/java/HelloFX
ls -l /Users/me/Documents/java/HelloFX.class
-rwxr--r-- 1 me staff 1336 Oct 30 16:01
/Users/murray/Documents/java/HelloFX.class
(I had already changed permissions to add `u+x` in case that was the
issue, but apparently that was not the trouble.
What's wrong?
(Yes, `$PATH_TO_FX` does point to `javafx-sdk-11/lib`.)
——
Mathematics & Statistics Dept.
University of Massachusetts Amherst
--
Steve Hannah
Web Lite Solutions Corp.
Murray Eisenberg
2018-10-30 22:20:01 UTC
Permalink
But the run command I gave, ending in just “HelloFX”, is exactly what was shown at https://openjfx.io/openjfx-docs/#install-javafx.

What exactly is it that I’d have to enter instead?

(I did try adding extension “.class” but that didn’t help.)
The "java" command expects a fully-qualified class name, not a file path as its argument.
E.g.
cd /Users/me/Documents/java
java --module-path $PATH_TO_FX --add-modules=javafx.controls HelloFX
This is under macOS Mojave (10.14).
javac --module-path $PATH_TO_FX --add-modules=javafx.controls /Users/me/Documents/java/HelloFX.java
But now if I attempt to run that...
java --module-path $PATH_TO_FX --add-modules=javafx.controls /Users/me/Documents/java/HelloFX
Error: Could not find or load main class .Users.me.Documents.java.HelloFX
Caused by: java.lang.ClassNotFoundException: /Users/me/Documents/java/HelloFX
ls -l /Users/me/Documents/java/HelloFX.class
-rwxr--r-- 1 me staff 1336 Oct 30 16:01 /Users/murray/Documents/java/HelloFX.class
(I had already changed permissions to add `u+x` in case that was the issue, but apparently that was not the trouble.
What's wrong?
(Yes, `$PATH_TO_FX` does point to `javafx-sdk-11/lib`.)
——
Mathematics & Statistics Dept.
University of Massachusetts Amherst
--
Steve Hannah
Web Lite Solutions Corp.
——
Murray Eisenberg ***@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 240 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305

Loading...