I have a JavaFX Tetris clone that I made originally using an ide and maven for dependency management. Everything works great - however, I want to know how everything is working under the hood, so I am trying to compile and run the app in my ubuntu terminal without using an ide or maven.
I have all my javafx dependencies and sqlite-jdbc driver/slj4 jars in my project structure.
Here are the steps I am taking to attempt to compile and run the app:
cd into project root directory, ~/Tetris, which contains the directories, lib, bin, and src. Lib contains javafx modules, bin is for .class file output and project resources (image files, sound files, database for top scores), and src contains source code.
compile the program:
javac --module-path lib --add-modules javafx.base,javafx.controls,javafx.graphics,javafx.media -d bin src/main/java/com/example/tetris/*.java
Everything works fine up to this point.
Run the program:
java --module-path lib --add-modules javafx.base,javafx.controls,javafx.graphics,javafx.media -cp bin:lib/sqlite-jdbc-3.45.3.0.jar:lib/sl4j-api-1.7.36.jar src/main/java/com/example/tetris/Main.java
In this command I add sqlite driver and sl4j to the classpath and attempt to run the program. At first, I get console output signifying that the program is running: Table 'top_players' created successfully. Number of rows in the table: 3 N: AAA, S: 10000 N: BBB, S: 5000
But shortly after, it crashes and I get this cryptic error:
Exception in Application start method
Exception in thread "main" java.lang.IllegalArgumentException: 0 > -4
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3782)
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3742)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:431)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
That is all it gives me, no other information. Does anyone have any idea what I could be missing or doing wrong?
If it helps, I am on an Ubuntu system. I have jdk and javafx added to my PATH. I am genuinely stumped. Thanks for anyone that sees and responds.
.javafile directly? (probably not, because then you wouldn't need the compile step in your question). That is supported by JEP 330, but it is limited in what it can do compared to running precompiled code. I advise compiling the code first (withjavac, via a build tool like Maven or Gradle), then running the compiled code. Instructions for that are at openjfx.io.