-
-
Notifications
You must be signed in to change notification settings - Fork 310
How to properly use TeaVMRunner? #1125
Description
I would like to turn a simple java class (bytecode) file into a simple wasm-gc binary file; As far as I understand TeaVMRunner is the tool I need to use for this, but if not please point me in the correct direction;
I don't quite understand how to give it the parameters properly.
I am also not super familiar with the java world, so I apologise in advance.
At first I built it with the command in the readme (./gradlew publishToMavenLocal), but then I'm not sure why java does not pick it up from the classpath automatically
$ java org.teavm.cli.TeaVMRunner
Error: Could not find or load main class org.teavm.cli.TeaVMRunner
Caused by: java.lang.ClassNotFoundException: org.teavm.cli.TeaVMRunnerThen I tried running it with just IntelliJ IDEA, which after some fiddling worked
(I needed to comment out the lines renaming the apache commons cli utils in settings.gradle.kts, otherwise it would not build
Error: Unable to initialize main class org.teavm.cli.TeaVMRunner
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
Error: Unable to initialize main class org.teavm.cli.TeaVMRunner
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
Execution failed for task ':tools:cli:org.teavm.cli.TeaVMRunner.main()'.
> Process 'command '/usr/lib/jvm/java-25-openjdk/bin/java'' finished with non-zero exit value 1)
But with it building, I cannot figure out how to properly give it the correct parameters.
In the IntelliJ run configuration, I tried giving it various options:
--targetdir /mnt/cupcake/Projects/teavm/output/fannkuch -t wasm --classpath /mnt/cupcake/Projects/fannkuch-redux-javat/out/production/fannkuch-redux-java/ --entry-point main com.example.fannkuchredux
The help text says that I need a qualified main class
usage: java org.teavm.cli.TeaVMRunner [OPTIONS] [qualified.main.Class]
and as far as I understand com.example.fannkuchredux should be it, however I'm not sure how that is supposed to be picked up, I assume from the CLASSPATH, thats why I also included the --classpath option pointing it to where the class file that I want to turn into wasm is.
I also included that same directory in the project classpath in the IntelliJ run configuration, to be sure, but no dice :(
I also tried _start as the entry-point.
The main error I get is:
> Task :tools:cli:org.teavm.cli.TeaVMRunner.main() FAILED
INFO: Running TeaVM
Analyzing classes...java.lang.NullPointerException: Cannot invoke "org.teavm.model.ClassReader.getFields()" because the return value of "org.teavm.dependency.ClassDependency.getClassReader()" is null
at org.teavm.backend.wasm.WasmTarget.contributeDependencies(WasmTarget.java:418)
at org.teavm.vm.TeaVM.build(TeaVM.java:421)
at org.teavm.tooling.TeaVMTool.generate(TeaVMTool.java:540)
at org.teavm.cli.TeaVMRunner.build(TeaVMRunner.java:457)
at org.teavm.cli.TeaVMRunner.buildNonInteractive(TeaVMRunner.java:442)
at org.teavm.cli.TeaVMRunner.runAll(TeaVMRunner.java:405)
at org.teavm.cli.TeaVMRunner.main(TeaVMRunner.java:182)
Execution failed for task ':tools:cli:org.teavm.cli.TeaVMRunner.main()'.
> Process 'command '/usr/lib/jvm/java-25-openjdk/bin/java'' finished with non-zero exit value 254I'd appreciate some pointers towards the right direction, and to know what exactly I'm doing wrong.