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 |
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-04-2004, 12:38 AM
|
#1
|
|
Member
Registered: Jan 2004
Location: Atlanta
Distribution: FreeBSD, Ubuntu, OSX, Fedora
Posts: 669
Rep:
|
getting javax.swing.* to appear
On the unix labs at my university all of the java running performs without flaws - gui's included. Here is a simple java file that i try to run on both systems:
Code:
/**
* simple.java
*/
import javax.swing.*;
public class simple {
public static void main( String args[] ) {
JOptionPane.showMessageDialog( null, "Can you see me?" );
}
}
then i type:
Code:
$ javac simple.java
and it compiles fine (the prompt is returned without any output). On the university's unix machine, running the program produces what i expect - a single message dialog, with the text "Can you see me?" in it, with an OK button. However i cannot do that on my machine (mandrake 10 official). I have j2re1.4.2_05, j2sdk1.4.2_05, and jdk1.3.1_12 in /etc/java/.
When i type "java simple" on my machine, i get this:
Code:
$ java simple
Exception in thread "main" java.lang.NoClassDefFoundError: simple
at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.4.0.0)
at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.4.0.0)
at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.4.0.0)
at __libc_start_main (/lib/tls/libc-2.3.3.so)
$
any idea? i'm clueless...
thanks in advance
|
|
|
|
10-04-2004, 12:46 AM
|
#2
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Rep: 
|
Have you installed java in /etc/java?
That's strange. Because java is usually installed in /usr/java.
I think that it's trying to use the GNU gcc java instead of Sun Java and that's where the error occurs.
|
|
|
|
10-04-2004, 12:49 AM
|
#3
|
|
Member
Registered: Jan 2004
Location: Atlanta
Distribution: FreeBSD, Ubuntu, OSX, Fedora
Posts: 669
Original Poster
Rep:
|
so.. how would I fix it?
|
|
|
|
10-04-2004, 12:54 AM
|
#4
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Rep: 
|
As a quick fix try calling java using the full path like in
Code:
/etc/java/j2sdk1.4.2/bin/java simple
substitute the path I gave with the actual path in which your Sun java executable resides on your system.
Or if you want to fix the whole problem, then make symbolic links to all the Sun java executables in your /usr/bin directory.
PS. I just tried your program on my system and it works fine.
|
|
|
|
10-04-2004, 01:15 AM
|
#5
|
|
LQ Newbie
Registered: Sep 2004
Location: India
Distribution: Fedora core1, PCQ Linux2004, SuSE8
Posts: 13
Rep:
|
or u can set the JAVA_HOME variable and export it on the cmd line. Another method is set the above variable in ur .bash_profile. That should do the trick.
|
|
|
|
10-04-2004, 01:46 AM
|
#6
|
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
It sounds more like a CLASSPATH problem. try adding . (current dir) to your CLASSPATH
|
|
|
|
10-04-2004, 10:24 AM
|
#7
|
|
Member
Registered: Jan 2004
Location: Atlanta
Distribution: FreeBSD, Ubuntu, OSX, Fedora
Posts: 669
Original Poster
Rep:
|
I'm sorry, i meant the path /usr/java! I somehow miss-typed that. Apologies. Anyway
I have
/usr/java/j2re1.4.2_05/bin/java
/usr/java/j2sdk1.4.2_05/bin/java
/usr/java/j2sdk1.4.2_05/bin/javac
and take a look at this:
Code:
$ whereis java
java: /usr/bin/java /usr/share/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Jul 5 21:12 /usr/bin/java -> /etc/alternatives/java*
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 23 Jul 5 21:12 /etc/alternatives/java -> /usr/bin/gcj-java-3.3.2*
That's just a messy system of linking...
Either of the /usr/bin/j2*/bin/java work on my other programs that use javax.swing.JFrame, but somehow javax.swing.JOptionPane isn't working.. maybe i don't have it?
*edit, ok.. here's what i found out: I compiled it with javac which is in the same path above (doing the 'whereis'), and when i recompiled the .java file (any) with the javac found in the /usr/java/j2sdk--/bin/javac and then ran it with the java in the same folder it worked! so my other java thing must just not be... good? Anyway thank you for all of your help (i would not have been able to get it myself)! :-D I will redo the links in /etc/bin when i have time later (for now i have bash aliases set).
-alex
|
|
|
|
10-05-2004, 09:48 AM
|
#8
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
Quote:
|
so my other java thing must just not be... good?
|
Your other java is the gnu java compiler, with its strengths and weaknesses, and is unrelated with Sun's products (j2re & j2sdk).
Quote:
|
I will redo the links in /etc/bin
|
No, in /usr/bin ! 
|
|
|
|
10-05-2004, 10:06 AM
|
#9
|
|
Member
Registered: Jan 2004
Location: Atlanta
Distribution: FreeBSD, Ubuntu, OSX, Fedora
Posts: 669
Original Poster
Rep:
|
arg! yes, /usr/bin... sorry. /etc/ will die
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:43 PM.
|
|
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
|
|