I wrote an application with JavaFX and I would like to run it like a "native" app in Ubuntu.
So I created the following desktop file and put it in ~/.local/share/applications:
[Desktop Entry]
Name=Notes
Exec=java -jar /home/namhto/dev/Notes/build/libs/notes-1.0.0.jar
Icon=/home/namhto/dev/Notes/build/libs/icon.png
Type=Application
Terminal=false
The desktop icon is created but when launching it from the gnome desktop, nothing happens. Running the command java -jar /home/namhto/dev/Notes/build/libs/notes-1.0.0.jar from a terminal effectively starts my app.
I tried to mark the jar file as executable in Ubuntu but it does not change anything.
I would start with using /the/absolute/path/to/java for your exec command (which you can find out via which java for example), instead of a relative one. Maybe your ENV setup doesn't have java in $PATH somehow.
Anything else looks good to me.
Related
How can I make a .jar file from my JavaFX program without having to tell the computer where the modules are located:
javaw --module-path c:\devel\javafx\lib --add-modules javafx.controls,javafx.fxml -jar myProgram.jar
Let's say for example, that I wish to send the program to my friend, who doesn't have JavaFX libraries on his/her computer.
I just wanto make it work so, that when you write:
java -jar myProgram.jar
It opens
Why not go the full way and create a real platform installer as you would do it with any other software? Have a look at this tutorial which I co-authored (so I am biased): https://github.com/dlemmermann/JPackageScriptFX
So, I am trying to run a program from jar files. It uses javaswing and has a gui.
The program runs fine in netbeans and in eclipse.
When I try to run it from the exported jar file it says this:
Unable To Install Java
There are errors in the following switches:
"C:\Users\CNC Department\Desktop\ValveConversion.jar";.
Check that the commands are valid and try again.[java installation not complete
Now, I also tried doing it from the command prompt. Here is what came up:
[cmd prompt attempt][1] [1]: https://i.stack.imgur.com/7reZ3.png
So, I reinstalled the java JDK, java SDK, netbeans and eclipse. The issue is still occurring in both command prompt and from running the jar file directly.
What am I doing incorrectly here? What do you recommend that I do to get this to run from a .jar file?
You need to set the java path
Open a cmd with elevated privileges and run this command to set the JAVA_HOME environment variable using setx command:
setx JAVA_HOME -m "C:\Program Files\Java\jdk-11.0.2"
Then restart the cmd and run java -version to check if it's all ok.
For reference setx command documentation
Or simply use the following snippet if you prefer to use java without setting the PATH variable:
"C:\Program Files\Java\jdk-11.0.2\bin\java" -jar "C:\Users\CNC Department\Desktop\ValveConversion.jar"
I've tried setting the Custom User Interface GPO option to
java -jar GyroUI.jar
as well as using the full path
C:\Program Files\jre7\bin\java.exe -jar GyroUI.jar
But neither seem to result in anything except the desktop background.
I know this works normally as I can run the jar file just fine using the command prompt, and I get the UI as expected.
C:\Program Files\jre7\bin\java.exe -jar "C:\Program Files\Sahara\GyroUI.jar"
Ended up being the solution, the problem was being caused by the application crashing, not by the shell failing to launch.
I made a program which runs fine on windows. When I moved it over to CentOS, I got this error:
Error: Could not find or load main class org.wbc.WBCController
This is the file setup and .sh on linux:
And this is the file setup and .bat on windows:
Does anybody know what the problem is, and how I can fix it?
Java will respond with this error even if it cannot find the file wbc.jar. I am guessing that that is your problem. You might want to see that your are executing the shell script from within the right working directory.
Check to see if you can run wbc.sh from the console or put this in wbc.sh to make sure it searches for the jar in the same directory as the shell script:
#!/bin/sh
java -cp `dirname $0`/wbc.jar org.wbc.WBCController
I have a tiny batch file to kick off my java app:
its code is something as simple as
java -jar myapp.jar
(in reality it's slightly more complicated as we set a few properties)
A friend of mine has a mac. He has java installed on his mac.
But how do we run this batch from mac ?
Put the following code into a file and run chmod +x <filename> to make it executable.
#!/bin/sh
java -jar myapp.jar
If the Java app. is a desktop app. with a GUI, a good way to launch it is using Java Web Start. JWS provides the ability to set properties in the JNLP launch file.
JWS works on all desktop JREs. E.G. it will work on Windows, Mac. and *nix.