question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example Program not working

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
TerryGuocommented, May 10, 2021

@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.

0reactions
t-katsumuracommented, Sep 14, 2022

Hi there. I had the same problem. Creating a bytecodertest folder and adding package bytecodertest did not work for me.

But finally, I solved with this way.

This is the directry structure

<current directry>
├ bytecodertest
│ └ HelloWorld.java
└ bytecoder-cli-2021-11-02-executable.jar

and HelloWorld.java is

package bytecodertest;
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

then, generate bytecodertest/HelloWorld.class with

javac bytecodertest/HelloWorld.java

After that, generate bytecodertest/HelloWorld.jar. This step is not written in the docs

jar cvf bytecodertest/HelloWorld.jar bytecodertest/HelloWorld.class

Finally, run this to obtain bytecoder.js (or bytecoder.wasm)

java -jar bytecoder-cli-2021-11-02-executable.jar -classpath=bytecodertest/HelloWorld.jar -mainclass=bytecodertest.HelloWorld -builddirectory=. -backend=js -minify=false

My environment is

openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Program Not Responding: Why Does It Happen & How to Fix It
If the programs are not responding on Windows 10 and 11 it might be a problem with the app itself or the memory....
Read more >
Why Do Windows Programs Stop Responding?
When a Windows program stops responding, freezes, or becomes unresponsive it can be caused by many different problems. For example ...
Read more >
How to Fix the "Application Is Not Responding" Error on ...
How to Fix the "Application Is Not Responding" Error on Windows · 1. Run a System File Checker Scan · 2. Update and...
Read more >
Program not running in Visual Studio 2019 - Microsoft Q&A
Before writing the program, try creating a project: go to menu, File, New, Project, select C# language, select “Console App (.NET Framework”), ...
Read more >
Computer Basics: Basic Troubleshooting Techniques
Simple solutions to common problems. Most of the time, problems can be fixed using simple troubleshooting techniques, like closing and reopening the program....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found