LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2006, 05:18 PM   #1
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Rep: Reputation: 15
Can't get java programs to run in Suse


I'm having some trouble getting my homework done....... :-( We're supposed to be writing java programs using a simple text editor and a command prompt program right now (no editors like jGrasp allowed yet). So I got the JDK all installed and I can set the path to the java compiler so when I say javac and it runs the compiler. But when I start a new session the path is back to where it was. How do I get the path to stay what I set it to permanently. Also, I can't execute the programs after I compile them. I've tried just saying "java Myprogram" and "java -classpath '/home/user/directory' Myprogram" and a million other things. What needs to be done here? I'm sure they are simple solutions, I just need a finger in the right direction. Thanks.
 
Old 09-03-2006, 05:25 PM   #2
debiant
Member
 
Registered: Jul 2006
Distribution: Source Mage 0.9.6
Posts: 196

Rep: Reputation: 30
export JAVA_PATH(or whatever)=/path/to/...
in your .bash_profile in your home directory

to run after compilation...
You also have to chmod 755 <filename>

Last edited by debiant; 09-03-2006 at 05:27 PM.
 
Old 09-03-2006, 07:53 PM   #3
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
hmm, I'm still not getting either problems to work. Can someone elaborate? Thanks for the info.
 
Old 09-04-2006, 10:01 AM   #4
shorun
Member
 
Registered: Mar 2006
Location: belguim
Distribution: fedora, mandriva, suse
Posts: 148

Rep: Reputation: 15
this issue is posted on the forum some weeks ago. try searching the forum for "java" for exact sollution. i howerver found it in the java manual itselve. get it from www.java.com.

it should tell you all about what to do.
 
Old 09-04-2006, 02:44 PM   #5
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Making progress...

I just experimented a ton and finally was able to get the PATH set to what I needed. But I'm still having problems running the .class file after compilation. I searched the forums and read through the sun manual...nothing. Here is what I'm trying:

Code:
kyle@Kyle:~/Desktop/Applications> echo $PATH
/home/kyle/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/src/bin:/usr/bin/jdk1.5.0/bin:/home/kyle/Desktop/Applications
kyle@Kyle:~/Desktop/Applications> ls
Converter.java  Images
kyle@Kyle:~/Desktop/Applications> javac Converter.java
kyle@Kyle:~/Desktop/Applications> ls
Converter.class  Converter.java  Images
kyle@Kyle:~/Desktop/Applications> chmod 755 Converter.class
kyle@Kyle:~/Desktop/Applications> ls
Converter.class  Converter.java  Images
kyle@Kyle:~/Desktop/Applications> java Converter
Exception in thread "main" java.lang.NoClassDefFoundError: Converter
   at gnu.java.lang.MainThread.run (libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: Converter not found in gnu.gcj.runtime.SystemClassLoader{urls=[], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.Class.forName (libgcj.so.7)
   at gnu.java.lang.MainThread.run (libgcj.so.7)
kyle@Kyle:~/Desktop/Applications>
What am I doing wrong? Once I get this I'm golden. Thanks

Last edited by krutten1986; 09-04-2006 at 02:46 PM.
 
Old 09-04-2006, 03:16 PM   #6
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 51
You are using GCJ as Java Virtual Machine. GCJ is far from being a complet JVM. Install the java.sun.com virtual Machine. It might be available from your package manager or Yast2.
 
Old 09-04-2006, 03:46 PM   #7
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
ok, I installed the jvm. How do I use it instead of the GCJ? I've read that it typically means losing openoffice for some reason....? What a nightmare...

Last edited by krutten1986; 09-04-2006 at 04:35 PM.
 
Old 09-04-2006, 04:28 PM   #8
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Rep: Reputation: 30
Quote:
Originally Posted by krutten1986
ok, I installed the jvm. How do I use it instead of the GCJ? Could the GCJ be embedded in my JDK? Do I need to remove it somehow? Thanks for the info.
If your using suse the following should work

Code:
cd $HOME/bin
ln -s /location/where/java/bin/java
ln -s /location/where/javac/bin/javac
ln -s /location/where/javadoc/bin/javadoc
This will override the system wide setting for your user.
this way from now on java,javac, and javadoc will be called from the sun java package.

If you want to remove the gcj then open yast --> applications --> search java --> click icon till u see the dumpster --> click install/update and it will uninstall.

Last edited by Fredstar; 09-04-2006 at 04:30 PM.
 
Old 09-04-2006, 05:11 PM   #9
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
I tired those commands Fredstart suggested and then gave the whole process another whirl. It's still calling from libgcj it looks like:

Code:
kyle@Kyle:~/Desktop/Applications> java Converter
Exception in thread "main" java.lang.NoClassDefFoundError: Converter
   at gnu.java.lang.MainThread.run (libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: Converter not found in gnu.gcj.runtime.SystemClassLoader{urls=[], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.Class.forName (libgcj.so.7)
   at gnu.java.lang.MainThread.run (libgcj.so.7)
So I went to remove CGJ and libcgj and it yelled at me saying that Open Office depended on it. I don't mind removing the version of open office that is native to SUSE and reinstalling the full version from their site but before I go about doing that I thought I should ask how to properly remove open office. Just search for openoffice.org in yast -> Software Management and delete everything that comes up? Then delete gcj the same way? Then when I run a java program it should go right to the jre right? Thanks
 
Old 09-04-2006, 05:18 PM   #10
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Rep: Reputation: 30
Quote:
Originally Posted by krutten1986
I tired those commands Fredstart suggested and then gave the whole process another whirl. It's still calling from libgcj it looks like:

Code:
kyle@Kyle:~/Desktop/Applications> java Converter
Exception in thread "main" java.lang.NoClassDefFoundError: Converter
   at gnu.java.lang.MainThread.run (libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: Converter not found in gnu.gcj.runtime.SystemClassLoader{urls=[], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.ClassLoader.loadClass (libgcj.so.7)
   at java.lang.Class.forName (libgcj.so.7)
   at gnu.java.lang.MainThread.run (libgcj.so.7)
So I went to remove CGJ and libcgj and it yelled at me saying that Open Office depended on it. I don't mind removing the version of open office that is native to SUSE and reinstalling the full version from their site but before I go about doing that I thought I should ask how to properly remove open office. Just search for openoffice.org in yast -> Software Management and delete everything that comes up? Then delete gcj the same way? Then when I run a java program it should go right to the jre right? Thanks
If u want yes thats how you would remove it.

Before doing that i would reboot or re-log. your home /bin is supposed to take precedence over the other /bin dir. If u dont want to remove packages replace java and javac in all the following dir.

/usr/local/bin
/usr/bin
/$HOME/bin

I suggest re-logging before you try anything else.


ALSO

If you compiled your program with the old version of java (GCJ) then delete the .class file and re-compile your .java file.

Another thing go to java.sun.com and download the new jdk package. Sun builds and maintains the package pointless downloading for a third party.

once there download the .bin (without rpm)

chmod a+x jdk-5_08.bin
./jdk-5_08.bin Agree to the license and let it unpack.

move that folder that it unpacks to your /home/YOU <-- folder

then do what i suggested with this java package.

cd /home/YOU/bin
ln -s /home/YOU/jdk-5_08/bin/java

and do the same for javac, and javadoc

Last edited by Fredstar; 09-04-2006 at 05:26 PM.
 
Old 09-04-2006, 08:16 PM   #11
krutten1986
LQ Newbie
 
Registered: Aug 2006
Location: Denver
Distribution: Suse 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
You sir are a genius. Works perfectly and I didn't even have to remove CGJ and lose openoffice. Thanks A TON for the help, I really appreciate it.
 
  


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
can't run my java programs crazyzombie Linux - Newbie 1 09-23-2005 02:42 PM
How to run Java programs in a sandbox fpmc Programming 0 07-07-2004 04:57 AM
trying to run programs in JavaDesktop from SuSE bcottam Linux - Distributions 4 04-12-2004 07:18 PM
run java programs from the command line...howto? rmanocha Programming 3 03-06-2004 03:50 AM
can't run X programs as root under suse 8.2 Moses420ca Linux - Newbie 1 09-05-2003 09:00 PM


All times are GMT -5. The time now is 12:49 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration