jpackage not working on Windows 10 and JDK 16 - java

trying to use jpackage for one of my projects, but does not work, crashing with a 103 error code.
Command:
jpackage.exe --main-jar evomaster.jar --input core/target/ --type msi
Error:
java.io.IOException: Command [C:\Program Files (x86)\WiX Toolset v3.11\bin\light.exe, -nologo, -spdb, -ext, WixUtilExtension, -out, C:\Users\arcur\WORK\code\EvoMaster\Main-1.0.msi, -sice:ICE27, -loc, C:\Users\arcur\AppData\Local\Temp\jdk.jpackage3073169401587857747\config\MsiInstallerStrings_en.wxl, -cultures:en-us, C:\Users\arcur\AppData\Local\Temp\jdk.jpackage3073169401587857747\wixobj\main.wixobj, C:\Users\arcur\AppData\Local\Temp\jdk.jpackage3073169401587857747\wixobj\bundle.wixobj] in C:\Users\arcur\AppData\Local\Temp\jdk.jpackage3073169401587857747\images\win-msi.image\Main exited with 103 code
JVM:
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)
OS Name Microsoft Windows 10 Pro
Version 10.0.18363 Build 18363
Any clue (of what I am doing wrong) or workaround (if someone has already faced this problem)?
UPDATE:
after the suggestion of Jorn Vernee, I ran the light command directly, to see the error messages. it is full of:
C:\Users\arcur\WORK\code\EvoMaster\foo\config\bundle.wxf(14413) : error LGHT0103 : The system cannot find the file 'C:\Users\arcur\WORK\code\EvoMaster\foo\images\win-msi.image\Main\app\classes\org\evomaster\core\search\service\Archive$sortAndShrinkIfNeeded$inlined$thenBy$2.class'.
what all these error messages have in common is that they are related to inlined classes. The program is written in Kotlin, and the Jar is built with maven-assembly-plugin

thanks to a discussion on Reddit I found a solution: you need to take your app.jar file out of the target folder, and put it in a folder (e.g., foo) that has only that file. then, use this new folder for the --input command.
The source of the problem seems light.exe not liking file paths that are too long... but all the other files under target are unnecessary when dealing with a uber-jar.

Related

How to run a jar that uses JavaFx with the --enable-preview tag in cmd/terminal?

Edit: Updated my question to better reflect what my problem was. Original Question: Is there a way to prevent Jar files exported in VScode from compiling using --enable-preview?
I'm working on a java project in VScode that uses JavaFX. Whenever I export a jar of the project using the Export Jar button and try to run the jar in cmd, I keep getting this error:
Error: LinkageError occurred while loading main class MyProgram
java.lang.UnsupportedClassVersionError: Preview features are not enabled
for MyProgram (class file version 61.65535). Try running with '--enable-preview'
Whenever I try to use the --enable-preview tag I get the following:
Error: JavaFX runtime components are missing, and are required to run this application
This is my JDK I use and I have JavaFX version 17.0.1.
openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment Microsoft-28056 (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM Microsoft-28056 (build 17.0.1+12-LTS, mixed mode, sharing)
Other solutions to similar problems seem to be issues with having multiple JDKs but I've only have this JDK downloaded on my device and I've only ever had this version downloaded. JavaFX is properly configured to my project and my JAVA_HOME path is to the JDK folder & Path's path is to the JDK bin.
The program runs fine when I run it in VScode, its when I export the jar and try to run it in cmd or terminal that this error pops up.
I tested it with a basic print hello world jar (not using JavaFX) and I get the same error too but no error appears when I run with the --enable-preview tag.
Thanks to help in the comments & this blog, adding the following to your VM arguments:
--module-path path/to/your-version-of-javafx/lib" --add-modules javafx.controls,javafx.fxml
and running the following command in cmd/terminal
java --enable-preview --module-path path/to/your-version-of-javafx/lib" --add-modules javafx.controls,javafx.fxml -jar MyProgram.jar
Allows the jar run without errors.
The blog also has other solutions/methods to dealing with this problem as well.

Issues with javac-algs4 compiler

I am trying to use Princeton Course specific Java Compiler (javac-algs4) on my windows machine and am seeing this error:
$ javac-algs4
warning: [path] bad path element "/usr/local/lift/lib/algs4.jar": no such file or directory
javac: no source files
This is related to Princeton Algorithms 1 Course. I followed the instructions on installing IntelliJ Idea from https://lift.cs.princeton.edu/java/windows/ and other steps to configure CLASSPATH.
javac and java work ok on HelloWorld programs, but I am expecting javac-algs4 to work for programs that use Course specific libraries.
It seems to me like a Unix Path may be hidden in the JAR file that I`m using in the CLASSPATH, and that may be breaking things for me. (Notice the /usr/local... directory in my error)
What steps could I take to troubleshoot and resolve the error?
Other Version Info:
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
Javac Version: javac 10.0.2

Can't run java applications

I have trouble when trying to open my jar files with the following command:
java -jar software.jar
They load until a certain point and then nothing happens.
I deinstalled default-jdk and OpenJDK with synaptic and re-installed it with apt-get, but nothing changed. I had a similar problem one month ago and solved it (apparently only temporarly) by deleting the package gcj-5-jre-lib (5.4.0-6ubuntu1~16.04.4) (Java runtime library for use with gcj (jar files))
The following outputs will help:
java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
javac -version
1.8.0_131
My variables $JAVA_HOME and $JRE_HOME were correctly added to my $PATH.
I'm on Ubuntu 16.04
EDIT
Here is an example of what I get when I try to start PhyDE.jar
java -jar PhyDE.jar
Welcome to PhyDE 0.9971!
Reading preferences.
Creating PhyDE-Application window
Checking for updates...
You are using the latest version of PhyDE
Done with checking for updates
When checking the core use with the command top I see that the process is active, but the user interface does not open as it usually does. I am located in the folder where the jar file is, and same happens with other jar files.

Open MPI's Java bindings

I'm trying to build the new Java bindings of Open MPI (v.openmpi-1.9a1r29661) on Macbook Pro running Mavericks (OSX 10.9). I have the JDK 7 installed:
^_^:examples demirelo $ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
I configured the OMPI with that command:
./configure --enable-mpi-java --with-platform=optimized --with-jdk-dir=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home --prefix=/Users/demirelo/libs/openmpi
which is followed by the usual suspect:
make all install
When I tried to run the HelloWorld example, I received the following runtime error:
^_^:examples demirelo $ ../bin/mpijavac Hello.java
^_^:examples demirelo $ ../bin/mpirun -np 1 java Hello
JAVA BINDINGS FAILED TO LOAD REQUIRED LIBRARIES
-------------------------------------------------------
Primary job terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
Moreover, the ~/.bash_profile has the correct path to the /lib folder.
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/demirelo/libs/openmpi/lib/
It's quite mysterious which libraries failed. Previously, I was able to build slightly older version (openmpi-1.9a1r28578) on Lion and still use it on Mavericks. This time I needed a freshly compiled OMPI but didn't work out. I'm wondering if anyone else had the same issue with Mavericks and was able to fix it.
This appears to be a bug in Open MPI that is comprised of at least two issues:
OMPI is hard-coded to try to dlopen libmpi.so, which is the wrong name on OS X (it should be libmpi.dylib).
Even after I fix that, I'm running into another Java error that I need to run by the Java programmers.
Apparently, we haven't tested the OMPI Java bindings on OS X in a long time. :-(
Such is the life of running against the SVN trunk. Sorry!

Ant and Classpath

I just started to learn Java using Thinking in Java book, and have some troubles using ant.
I'm using Ubuntu 12.04, and have openjdk 7 java installed. I also setup the CLASSPATH to be the code folder
When I run ant in code folder, this is the output:
Exception in thread "main" java.lang.RuntimeException: JDK 1.4.1 or higher is required to run the examples in this book.
[CheckVersion] at com.bruceeckel.tools.CheckVersion.main(Unknown Source)
However when I run java -version, this is the output:
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
How to setup ant and classpath correctly?
P/S: Thanks everyone for the help!!! I figured out why it fails to check the version.
The testing condition is "if(minor < '4' || point < '1')" in CheckVersion.java. Yet my version is 1.6.024, eventhough 6>4 but 0<1 that's why it failed. I guess we need to rewrite the testing condition!
Try setting your JAVA_HOME environment variable to the install directory of your 1.6 JDK.
When you type "java -version", the command shell is using the first java executable it finds in your PATH. Ant probably looks for the java executable in the "bin" sub-directory of your JAVA_HOME directory.
To find the location of your java executable, type the following:
which java
and let's say you got the following output:
/usr/local/java1.6/bin/java
You would then set your JAVA_HOME variable to /usr/local/java1.6. Assuming a Bourne or Bash shell, the syntax for that would be
export JAVA_HOME=/usr/local/java1.6

Categories