Thank you, Philippe! I’m almost there! Please note, I’m doing this from the command line on a Debian GNU/Linux system with OpenJDK 10 installed:
$ java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Debian-1)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Debian-1, mixed mode)
$ javac -version
javac 10.0.2
I saw the haxe
command as shown in the StackOverflow post. I see that the -cp src
tells haxe
where to find my Haxe source code, so I changed my library directory to match:
my-haxe-lib/
README.md
src/
my_stuff/
Foo.hx
I see that the -java my_stuff
option tells haxe
where to put the output of compilation.
When I run the command from the my-haxe-lib directory:
haxe -cp src -java my_stuff -D no-root my_stuff.Foo
I get a lot of stuff generated in a newly-created my_stuff directory, including a my_stuff.jar. Woot!
I then copied that my_stuff.jar file into the-java-proj directory (which is just my own hello-world Java app). This directory contains a Main.java:
import my_stuff.Foo;
class Main {
public static void main(String[] args) {
System.out.println("Hello, Java!");
Foo.do_stuff();
}
}
I can build that project via javac -cp my_stuff.jar Main.java
, but when I run it (via java Main
) I get errors:
$ java Main
Hello, Java!
Exception in thread "main" java.lang.NoClassDefFoundError: my_stuff/Foo
at Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: my_stuff.Foo
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 1 more
Any ideas on where I’m going wrong?
Thanks!