Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-15-2009, 01:22 AM
|
#1
|
Member
Registered: Jan 2008
Posts: 49
Rep:
|
error in running java
I have installed jdk 1.6 .when I compile file (java)
it compiles creating a class file but when I use the
java command it gives errors .
$javac ArraySortSearch.java (compiles successfully : no errors)
$java ArraySortSearch
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: ArraySortSearch
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
at __gcj_personality_v0 (/root/Desktop/java.version=1.4.2)
at __libc_start_main (/lib/tls/libc-2.3.4.so)
at _Jv_RegisterClasses (/root/Desktop/java.version=1.4.2)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in [file:/usr/share/java/libgcj-3.4.6.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at _Jv_BytecodeVerifier.verify_instructions_0() (/usr/lib/libgcj.so.5.0.0)
at _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib/libgcj.so.5.0.0)
at _Jv_PrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at _Jv_WaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
...9 more
|
|
|
04-15-2009, 01:35 AM
|
#2
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
That message indicates you are not running jdk but gcj. The latter contains only a selection of the classes that were introduced in java 1.5 so it often causes compilation errors if code contains references to any of those newer classes.
Last edited by jay73; 04-15-2009 at 01:36 AM.
|
|
|
04-15-2009, 08:57 AM
|
#3
|
Member
Registered: Jan 2008
Posts: 49
Original Poster
Rep:
|
I am using JDK since I have compiled using javac and afterthat
used java command.
|
|
|
04-15-2009, 12:33 PM
|
#4
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
No, you are not. GCJ uses the java and javac commands, too, so that does not say much. Look at the details of the error messages instead to find out; it's "gcj" all over.
|
|
|
04-15-2009, 01:17 PM
|
#5
|
Member
Registered: Jan 2008
Posts: 49
Original Poster
Rep:
|
then how do i use the jdk to compile my java programs and
then run them .
|
|
|
04-15-2009, 01:26 PM
|
#6
|
Member
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653
Rep:
|
Which distro are you using? If it's Debian or one of it's offspring, then you could use update-alternatives:
Code:
update-alternatives --config javac
So long as the JDK is installed somewhere where the alternatives system can find it, you can select it from a menu. If not, you will probably find that javac is a symbolic link to the actual program - just modify the link to point to the version from the JDK.
|
|
|
04-15-2009, 01:35 PM
|
#7
|
Member
Registered: Jan 2008
Posts: 49
Original Poster
Rep:
|
I am using RHEL4 .
how do I modify the link to point to the version from the JDK so
that I can use javac and java
|
|
|
04-15-2009, 03:00 PM
|
#8
|
Member
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653
Rep:
|
You could do it like this:
Code:
$ which javac #find out where it is
/usr/bin/javac
$ file java # check that it really is a link
/usr/bin/javac: symbolic link to '/path/to/gcj/javac'
$ rm /usr/bin/javac # remove the link
$ ln -s /path/to/jdk/javac /usr/bin/javac # recreate it
The last two steps would need to be done as root (or using sudo). If file tells you that javac is actually the executable file, rather than a link, you should either remove gcj using yum, rather than rm'ing javac:
Code:
yum remove gcj # I believe, not so used to yum yet
... to avoid causing problems with the package management system, or create a symbolic link to javac in a directory that appears in the $PATH environment variable before /usr/bin (or wherever javac is located). For instance,
Code:
rob:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/rob/scripts
... shows me that /usr/local/bin appears before /usr/bin, so I could make a link to javac there, and it would take precedence over the link in /usr/bin:
Code:
$ ln -s /path/to/jdk/javac /usr/local/bin/javac
You'll probably want to do likewise for java as well (and definitely if you remove gcj).
Last edited by Robhogg; 04-15-2009 at 03:13 PM.
|
|
|
04-15-2009, 05:54 PM
|
#9
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
Well, you can always install openJDK from the fedora repositories. It is an open source implementation of the Sun JDK and it is available in RPM format.
Frankly, RHEL is about the worst choice you can make if you need to run the Sun JDK. To my knowledge, it is one the few distros that has made a point of refusing to include that type of software. Sure, it can be made to work but why bother - and although good as a basic solution, Robhogg's solution does not explain how to get the other thirty or so JDK executables to work or how to switch from one JDK to another one. And removing gcj is only feasible if you do not install Eclipse; if I remember well, it is one of its dependencies.
Last edited by jay73; 04-15-2009 at 05:58 PM.
|
|
|
04-16-2009, 12:13 PM
|
#10
|
Member
Registered: Jan 2008
Posts: 49
Original Poster
Rep:
|
is it possible to install openJDK from the fedora repositories
in RHEL 4 .
|
|
|
04-16-2009, 03:56 PM
|
#11
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep: 
|
I don't use RHEL so I can't tell. I believe that Red Hat has its own repositories for subscribers. In addition, there are a number of third party repositories, for example:
http://jpackage.org/
If you follow their instructions, you can install the Sun JDK. Jpackage has many java related package but - for licensing reasons - they require you to get the JDK directly from Sun, then you can use one of their packages to make installing it easier.
Then there is also
http://dag.wieers.com/rpm/packages.php
Many other packages there but it appears that the openJDK is not included.
|
|
|
All times are GMT -5. The time now is 03:38 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|