LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-01-2005, 11:42 AM   #1
sabliny
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
How to run a java jar file.


Operating system: Red Hat Linux 2.4.21-4.EL.
GUI interface: GNOME

How do I run a java jar file from the linux command line?

- Using GUI Natutilus 2.2.4 ( a graphical shell for GNOME), I tried to run
The jar file by double clicking on it, and nothing happens. It won't run.

How do I run it from the GUI session?


Thanks,

Sabliny
 
Old 11-01-2005, 12:37 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
man java


Cheers,
Tink
 
Old 11-01-2005, 12:55 PM   #3
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
Code:
java -jar filename.jar
 
Old 11-01-2005, 01:25 PM   #4
sabliny
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Original Poster
Rep: Reputation: 0
How to run a java jar file

Thanks for your reply.

The program I am trying to run is database maintenance program that uses Absolute layout in its database layout form.
I have added to my bash_profile : DISPLAY=:0.0 and exported it.

I tried : java -jar jfmu.jar

I got the following response.

Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java
:53)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:1
31)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi
ronment.java:68)
at java.awt.Window.init(Window.java:270)
at java.awt.Window.<init>(Window.java:318)
at java.awt.Frame.<init>(Frame.java:419)
at java.awt.Frame.<init>(Frame.java:384)
at javax.swing.JFrame.<init>(JFrame.java:150)
at com.sdiretail.fmu.Cfmu.<init>(Cfmu.java:44)
at com.sdiretail.fmu.Cfmu.main(Cfmu.java:707)


It looks like it is trying to bring up an X11 window to display the form.

Where do I go from here.

Thanks,

Sabliny.
 
Old 11-01-2005, 02:03 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
If you're trying to run the program as a different user
from the one who runs X you'll have to run
xhost +locahost
as the owner of the X session before running the
jar file.


Cheers,
Tink
 
Old 11-01-2005, 04:09 PM   #6
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
avoid root account login
 
Old 11-01-2005, 04:28 PM   #7
sabliny
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Original Poster
Rep: Reputation: 0
run a java jar file

I ran : xhost +localhost

Then I ran the script to run mu jar file that indluded :

java -jar $HOME/men4/jfmu/dist/jfmu.jar -classpath $HOME/men4/jfmu/build/classes
:$HOME/men4/jfmu:$HOME/men4/jfmu/org/netbeans/lib/awtextra -Djava.library.path=/
$HOME/men4/jfmu

Where $HOME points to my user home directory.


and I got the following error:


Exception in thread "main" java.lang.NoClassDefFoundError: org/netbeans/lib/awte
xtra/AbsoluteLayout
at com.sdiretail.fmu.Cfmu.initComponents(Cfmu.java:143)
at com.sdiretail.fmu.Cfmu.<init>(Cfmu.java:46)
at com.sdiretail.fmu.Cfmu.main(Cfmu.java:707)

Any ideas?

Thanks,

Sabliny
 
Old 11-05-2005, 02:59 PM   #8
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
- You have to include all jars in the classpath
- Adding the $HOME/men4/jfmu/org/netbeans/lib/awtextra in your classpath doesn't mean java will look for the jars in that directory($HOME/men4/jfmu/org/netbeans/lib/awtextra) by itself.

Exception in thread "main" java.lang.NoClassDefFoundError: org/netbeans/lib/awte
xtra/AbsoluteLayout
at com.sdiretail.fmu.Cfmu.initComponents(Cfmu.java:143)
at com.sdiretail.fmu.Cfmu.<init>(Cfmu.java:46)
at com.sdiretail.fmu.Cfmu.main(Cfmu.java:707)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
howto run a java.jar file in FC2-3 mickeyboa Fedora 1 02-11-2005 02:01 PM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 06:26 AM
Cannot not run executable jar file after set content type for download antony_csf Programming 1 12-08-2004 01:22 AM
how to run a jar file in redhat9.0 balanagireddy Linux - Newbie 10 06-07-2004 07:12 AM
Using Tomcat to run a .jar file davee Linux - Software 1 08-15-2003 06:47 AM


All times are GMT -5. The time now is 05:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration