Opening a jar file from the desktop

I have java-1.7.0-openjdk installed on a CentOS-6.3 x86_64 system. On
my desktop I have a jar file containing a calculator program which
runs fine on CentOS-5 and on MS-Windows machines.

On the CentOS-6 system when I right-click on the jar file and say open
with java nothing apparently happens. When I double-click on it then
I see a file browser window offering to extract the contents but there
are no contents visible, only an empty / directory. If I go to the
desktop in a terminal session and type java superbcalc.jar then I see
this message: "Could not find or load main class superbcalc.jar"

There is no CLASSPATH environment variable set by the system. If I
provide one and include the current directory '.' I get the same

CLASSPATH=. java superbcalc.jar
Error: Could not find or load main class superbcalc.jar

What has changed in CentOS-6 to stop this from working and how do I
get jar files to open and run using Java both from the command line
and from the desktop?


Re: Opening a jar file from the desktop

By Frank Cox at 02/01/2013 - 13:04

On Fri, 1 Feb 2013 10:42:23 -0500

Create a small script or a launcher (right-click on desktop, Create Launcher)
containing the following: java -jar nameofjar.jar