Launching JNLP from CentoOS 7 Gnome Desktop with PATH - java

I have a JNLP application that uses the local $PATH variable. It launches and behaves correctly from the web, command line, menu system, and Java control panel. When I launch it from the desktop shortcut on CentOS 7, the $PATH is simply
/bin:/lib:/usr/bin:/usr/lib:/usr/share/bin:/usr/share/lib
regardless of what else I put in the /etc/profile.d/, or ~/.bashrc, or anyplace else that I can find. It only seems to affect CentOS 7. CentOS 6.x, OS X, and Windows all behave normally when launching from their Desktop environments.
I am using Oracle's 32-bit Java 1.8.0_60 on the 64-bit CentOS 7 for specific application requirement reasons. I have uninstalled IcedTea, but still have OpenJDK 1.7 installed, though it is not used by the JNLP application and the alternatives have been configured to use Oracle's.

The best solution that I have found is:
Disable shortcut creation in the Java control panel > Advanced settings
Create a shell script that contains these two lines:
source /etc/profile
javaws < location-of-jnlp >
Create a .desktop file that calls the shell script
It's not an ideal solution, but it works for the short run.

Related

Java x64 interface refusing to run

I have a problem with a particular windows installation where any graphical element of java refuses to run.
Java has previously ran successfully on the current Windows installation, but was probably over 12 months ago.
This issue presented itself when I tried to run a .jar and no window ever opened (nothing showing signs of life in task manager).
Clicking 'Java' in control panel results in the 'waiting' cursor for a quarter of a second then nothing.
Running 'About Java' and 'Configure Java' shortcuts also results in this same behavior.
I have tried:
Uninstalling Java, rebooting and re-installing the latest x64 version (1.8.0_271)
Running 'JavaRa' (JavaRa) in the hopes of cleaning up something that the uninstallation missed
Removing '.\Oracle\Java\javapath' from PATH environment variable as suggested by java x86 stackoverflow question
The only signs of life I can get is in powershell/command prompt.
Running java -version results in the output as expected:
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
However running, java -jar 'jarfile.jar' does not launch the application window.
Amendment:
I have resorted to trying a fresh copy of Windows installed on a USB drive. I have installed the same x64 version of Java using the same offline installer .exe
Java works normally on this fresh install.
Running a .jar on existing windows install
running java -jar "technicLauncher.jar" results in
Settings for exe: /D:/TechnicLauncher.jar
Portable settings dir: E:\technic
At this point, the applications user interface does not open, powershell displays: Setting up logging then the program exits.
Running a .jar on fresh windows install
running java -jar "technicLauncher.jar" results in
Settings for exe: /D:/TechnicLauncher.jar
Portable settings dir: E:\technic
At this point, the applications user interface opens and I can continue as normal.

How to simply deploy Java/JavaFX applicartion on Max OS?

I designed a Java application with some JavaFX features, whose ideal target is the Java 8 JRE. The application works fine, and has to be ran on several OS, like Windows, Mac OS or Linux.
The application is designed with Eclipse and JavaFX scene builder.
Thought I manage in installing manually it on Mac OS, I would need a more automated process for end-users: so far, I must copy the files, run a JRE installer if needed and finally launch the application.
Now what I need is some kind of script that would do the job in one click:
- Check whether the appropriate JRE is available or not
- Install or upgrade the appropriate JRE
- Copy the needed files
- Set a shortcut on the desktop
- Launch the application.
Does anybody know which tool I should try ?
Thanks!

Java applications don't start via .apps in Finder

I have Mac OS 10.9.3 installed, and when entering java -version in the Terminal it shows:
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
My problem is that applications which use Java don't work when double-clicking on the .app folders. For example, TuxGuitar just does nothing, and Eclipse gives the No Java virtual machine error. When launching them with the command
open TuxGuitar.app
open Eclipse.app
.. they work both. What could be the problem?
I had the same problem and I fixed this by installing a patch from apple at
http://support.apple.com/kb/DL1572?viewlocale=en_US.
Something is different in the environment of the shell you get in Terminal, compared with the environment Finder.app is running in. You need to figure out what's different.
A few relevant facts:
OS X windowed applications do not read your shell startup files like ~/.bash_profile, so changes you make there to your ${PATH} or ${JAVA_HOME} will not affect windowed applications.
It used to be the case that OS X windowed applications read ~/.MacOSX/environment.plist but apparently that's no longer true in 10.9 Mavericks; see for example this other StackOverflow question.
Java on Mac OS X keeps changing, and can be installed and controlled in a variety of ways. So it's hard to give a general answer; it depends on the history of your system.
Java Mac GUI applications can place restrictions on which JVM will run them, in Contents/Info.plist of the application bundle; look for key JVMOptions and in particular at JVMVersion within that.
Things to try:
Open System Preferences and see if you have a Java Control Panel. If you do, you can use it to select which JVMs are available for running GUI applications, and in what order they will be tried.
Open a "clean" shell by running env -i /bin/sh and then try running /Applications/TuxGuitar.app/Contents/MacOS/TuxGuitar inside that shell; you may get a useful error message.
Use /usr/libexec/java_home -V to see a list of JVMs the OS knows about.
/usr/libexec/java_home -v 1.7 to see which JVM the OS would choose for an application that needs Java 7.
I have the exact same issue after upgrading to Mavericks and I noticed it with muCommander.
As I can run the app manually from the command line, I have the following workaround which I am quite happy with:
Create a shell script workflow using Automator:
Spotlight -> Automator -> Workflow -> "Run Shell Script" -> [shell command]
Then save the Worflow, but instead of .workflow, choose file format Application. Now you have an App you can double-click.
Addendum 1: This is not the answer to your original question as I don't know exactly what the problem is (jbyler's answer might point you in the right directions here).
However, I assumed that your question implies Can I get double-click to work again?, and this workaround helped me to do that.
Addendum 2: I have JAVA_HOME set up and the same version installed as you have. This is a screenshot for the Workflow in Automator:
I managed to fix this by installing the developer kit.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
I had the same problem. Open the /Applications/TuxGuitar.app/Contents/MacOS/TuxGuitar with your favourite text editor (it's a shell script) and add "-d32" option to the last line "exec java ...." (position doesn't matter). This will launch java in 32-bit mode. Alternatively you can launch TuxGuitar with "-d32" option (it passes arguments to java) from the terminal.

Eclipse only sees JDK with sudo

I have to start by saying that I have just switched to Ubuntu from Windows and I am new to Linux in general. Coming from Windows, I really am not familiar with how exactly the permissions work, the Linux file system, where I am able to create folders that I can use without the sudo command etc.
I use eclipse on a daily basis for android development and other simple java swing projects. I was able to download and extract the latest available version of eclipse (kepler) to this path: /opt/eclipse. Inside this directory is the eclipse executable and other eclipse related files.
I also installed the JDK and verified with the java -version command. It says:
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
I am running on a 64 bit CPU architecture so both programs are the 64 bit version.
Now, my problem is that if I open eclipse from the Unity dash or from the file explorer, it give me this error:
However if I run sudo eclipse in the terminal, everything runs just fine as long as I do it as the super user. I have a hunch that the JDK is installed in a folder that is restricted to normal users and only works if I run the sudo command but this is just a hunch. As I said, I am new to Linux and I am not really sure what I am doing wrong here, I am learning as I go. I need a good explanation as to how to make it start from the Unity dock without the sudo command. Thanks in advance!
You'll want to use the chmod command from the terminal to change the permissions on the Java folder. See this link for more information:
http://www.linux.org/threads/file-permissions-chmod.4094/
Well after running the which java cmd, I noticed that the path to the JDK from the eclipse.ini file was not pointing to the correct location. I fixed the path and now it works. I don't know how the sudo cmd overrides the eclipse.ini path to JDK but well, it works

launching java applications in a cross platform way

I have a Java program, let's say it's called MyApp.jar
To run it on Linux, I just write a shell script called myapp.sh, which simply runs java -jar MyApp.jar and double click on it. Everything works well.
On Windows 7, I cannot assume that the java command will be in everyone's path (if that's what you call it on Windows), so I have to have a workaround and do something like create a batch script with this in it: "C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar MyApp.jar, which is obviously a Bad Solution... and it doesn't work on XP or Vista. It works on most Windows 7 machines though.
My application ships as a .zip file, the user extracts it to a folder MyApp, and then ideally will double click on something to invoke the program. So far it has a .sh script for Linux users to double click on, and a batch script for Windows 7 users (it works in most cases). It creates and consumes files in its own directory (MyApp).
What is the best way to invoke this program in a cross platform way?
Thanks!
As mentioned by biziclop, Java Web Start is commonly used to install/launch/update Java desktop apps.
As far as the JRE goes, it is usually sufficient to use the deployJava.js linked from that page above to ensure minimum necessary JRE is installed, and the elements in the JNLP file to specify any JRE micro-versions that are supported for the app.
Application launch
JWS can install desktop shortcuts and menu items when supported by the OS. Those can be specified in the launch file, or added/removed at run-time using services of the JNLP API.
If you can't deliver Java with your application, it might be a good solution to use JAVA_HOME to start it. It is set on, well... not all but many systems.
Definitly you should not use C:\Program Files (x86)... it is much better to use the environment variable %ProgramFiles%
Java application require a java runtime environment with a certain version to be installed on the target system.
The most convenient way, to my opinion, is to ship all libraries and documentation in a single archive and add start scripts for windows and *nix systems.
You could ship a JRE with your application too but then you'd have to support builds for different platforms...

Categories

Resources