smack42 / DriftingDroids

DriftingDroids - yet another Ricochet Robots solver program
https://github.com/smack42/DriftingDroids/wiki
GNU General Public License v3.0
41 stars 12 forks source link

Start.jar doesn't work on Ubuntu 21.04 with openjdk 11 #23

Closed rubo77 closed 1 year ago

rubo77 commented 2 years ago

java --version
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2, mixed mode, sharing)

$ ./start.jar 
invalid file (bad magic number): Exec format error

$ java ./start.jar
Error: Could not find or load main class ..start.jar
Caused by: java.lang.ClassNotFoundException: //start/jar
rubo77 commented 2 years ago

I tried downloading the latest Java SE Development Kit 17.0.1 from https://www.oracle.com/java/technologies/downloads/ and installing via

sudo apt install libc6-x32
sudo dpkg -i jdk-17_linux-x64_bin.deb

starting with java 17 gives the same error:


$ java17 ./start.jar 
Error: Could not find or load main class ..start.jar
Caused by: java.lang.ClassNotFoundException: //start/jar
smack42 commented 2 years ago

Please use this command: java -jar start.jar

By the way, this start.jar is the compiled program "appstart": https://github.com/smack42/appstart

rubo77 commented 2 years ago

When I try with -jar just nothing happens:

$ java -jar start.jar 
$ _ 

Now I tried

sudo apt-get install advancecomp
./buildjar.sh 

Which runs until this error:

Error: Unable to access jarfile /home/ruben/Programme/proguard6.2/lib/proguard.jar

I tried:

apt install libproguard-java
mkdir -p ~/Programme/proguard6.2/lib/
cp /usr/share/java/proguard.jar ~/Programme/proguard6.2/lib/

which gives me now:

$ ./buildjar.sh 
ProGuard, version 6.2.0
Reading input...
Reading program directory [/var/www/DriftingDroids/bin]
java.io.IOException: Can't read [/var/www/DriftingDroids/bin] (No such file or directory: bin)
        at proguard.InputReader.readInput(InputReader.java:219)
        at proguard.InputReader.readInput(InputReader.java:189)
        at proguard.InputReader.readInput(InputReader.java:167)
        at proguard.InputReader.execute(InputReader.java:95)
        at proguard.ProGuard.readInput(ProGuard.java:266)
        at proguard.ProGuard.execute(ProGuard.java:97)
        at proguard.ProGuard.main(ProGuard.java:591)
Caused by: java.io.IOException: No such file or directory: bin
        at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:50)
        at proguard.InputReader.readInput(InputReader.java:215)
        ... 6 more
unzip:  cannot find or open lib/driftingdroids.jar, lib/driftingdroids.jar.zip or lib/driftingdroids.jar.ZIP.
Failed stat file * [at void add_single(zip&, const string&, const string&, bool, bool, shrink_t):rezip.cc:358]
./buildjar.sh: Zeile 26: zipmerge: Befehl nicht gefunden
chmod: Zugriff auf 'lib/driftingdroids.jar' nicht möglich: Datei oder Verzeichnis nicht gefunden

I guess, I have to compilerun.sh first, but this gives also just an error:

$ ./compilerun.sh 
compile...
warning: [options] bootstrap class path not set in conjunction with -source 6
warning: [options] source value 6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
src/driftingdroids/ui/SwingGUI.java:151: error: diamond operator is not supported in -source 6
    private final JComboBox<String> jcomboRobots = new JComboBox<>();
                                                                 ^
  (use -source 7 or higher to enable diamond operator)
src/driftingdroids/model/Board.java:289: error: diamond operator is not supported in -source 6
        final List<Goal> result = new ArrayList<>(QUADRANTS[quadrant].goals);
                                                ^
  (use -source 7 or higher to enable diamond operator)
2 errors
4 warnings

run...
Error: Could not find or load main class driftingdroids.ui.Starter
Caused by: java.lang.ClassNotFoundException: driftingdroids.ui.Starter
rubo77 commented 2 years ago

strange, that, if I edit SwingGUI.java, I still get the same error, as if it was still the old file somehow cached or so ;?

rubo77 commented 2 years ago

$ java -Dappstart.verbose=true -jar start.jar
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: using java in /usr/lib/jvm/java-11-openjdk-amd64/bin
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: appstart dir: /var/www/DriftingDroids
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: launched from start.jar
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: look for application specific config file: start.properties
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: libs dir: /var/www/DriftingDroids/lib
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: classpath = /var/www/DriftingDroids:/var/www/DriftingDroids/lib/designgridlayout-1.11.jar:/var/www/DriftingDroids/lib/flatlaf-0.45-sources.jar:/var/www/DriftingDroids/lib/designgridlayout-1.11-sources.jar:/var/www/DriftingDroids/lib/flatlaf-0.45.jar:
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: vmoptions = -Xmx800M
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: main class = driftingdroids.ui.Starter
Dez. 12, 2021 3:01:55 NACHM. org.appstart.Starter main
INFORMATION: command line:
[/usr/lib/jvm/java-11-openjdk-amd64/bin/java, -Xmx800M, -Dapp.vm.options=-Xmx800M, -Dapp.main.class=driftingdroids.ui.Starter, -Dswing.defaultlaf=com.formdev.flatlaf.FlatIntelliJLaf, -cp, /var/www/DriftingDroids:/var/www/DriftingDroids/lib/designgridlayout-1.11.jar:/var/www/DriftingDroids/lib/flatlaf-0.45-sources.jar:/var/www/DriftingDroids/lib/designgridlayout-1.11-sources.jar:/var/www/DriftingDroids/lib/flatlaf-0.45.jar:, driftingdroids.ui.Starter]
smack42 commented 2 years ago

Yes, since release 1.3.9 the program requires Java 8 to build and Java 8+ to run. https://github.com/smack42/DriftingDroids/releases/tag/1.3.9

I never use this script compilerun.sh myself. I build and run the program in Eclipse and only use buildjar.sh when I build a release package.

smack42 commented 2 years ago

I have now fixed and simplified the build script (ProGuard and advzip are not used anymore) and also updated README-developer.txt

rubo77 commented 2 years ago

java-11-openjdk is Not Java 8+ ?

smack42 commented 2 years ago

Yes, java-11-openjdk is Java 8+

Appstart and DriftingDroids work fine with Java 8 and 11 on my Linux system. I tested them some time ago on Windows as well, with Java 8, 11 and 17 (or 16? don't remember)

rubo77 commented 2 years ago

still the app doesn't start with

java -jar start.jar

but this works:

./compilerun.sh
smack42 commented 2 years ago

Please use these commands:

./compilerun.sh   (and then quit DriftingDroids)
./buildrelease.sh
cd DriftingDroids_release
java -jar start.jar
rubo77 commented 2 years ago

This works.

Maybe since *.jar is in .gitignore, the start.jar in the root folder of the repository is not updated?

I tried cp the new start.jar into the root folder, but from there it still doesn't start.

I added a description how to start in #28

smack42 commented 2 years ago

start.jar just needs appstart.properties in the same folder and the program components (jar files) in sub-folder lib.

IMO we don't need more documentation on how to launch the program.

Users download a release package from https://github.com/smack42/DriftingDroids/releases, then they unzip it, have a look at README.txt and find that they just need to doubleclick on start.jar. If they are really curious they can find more information in the user documentation.

Developers probably clone the entire Git repository and may have a look at README-developer.txt to get some initial information.