Example Program not working
See original GitHub issueI can’t seem to get Bytecoder to work with any of the JavaFX programs I have. Running it on the HelloWorld program also gave me issues on two different machines or on different java version. I’m not sure if I’m missing something so this is what I did.
I create a file called HelloWorld.java with
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
I compile it with javac HelloWorld.java
I download the executable jar and run java -jar bytecoder-cli-2021-01-26-executable.jar -classpath=. -mainclass=HelloWorld -builddirectory=. -backend=js -minify=false
This throws
Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 10 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319) at java.base/java.lang.String.substring(String.java:1874) at de.mirkosertic.bytecoder.backend.js.JSMinifier.toClassNameInternal(JSMinifier.java:75) at de.mirkosertic.bytecoder.backend.js.JSMinifier.toClassName(JSMinifier.java:64) at de.mirkosertic.bytecoder.backend.js.JSSSACompilerBackend.lambda$generateCodeFor$10(JSSSACompilerBackend.java:995) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) at de.mirkosertic.bytecoder.backend.js.JSSSACompilerBackend.generateCodeFor(JSSSACompilerBackend.java:990) at de.mirkosertic.bytecoder.backend.js.JSSSACompilerBackend.generateCodeFor(JSSSACompilerBackend.java:61) at de.mirkosertic.bytecoder.backend.CompileTarget.compile(CompileTarget.java:310) at de.mirkosertic.bytecoder.cli.BytecoderCLI.main(BytecoderCLI.java:132) ... 8 more
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
@cd155 I ran into same problem and fixed it by creating a folder named bytecodertest and then moving HelloWorld.class into it. Then everything works fine.
Hi there. I had the same problem. Creating a
bytecodertest
folder and addingpackage bytecodertest
did not work for me.But finally, I solved with this way.
This is the directry structure
and
HelloWorld.java
isthen, generate
bytecodertest/HelloWorld.class
withAfter that, generate
bytecodertest/HelloWorld.jar
. This step is not written in the docsFinally, run this to obtain
bytecoder.js
(orbytecoder.wasm
)My environment is