ProgrammingThis 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.
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.
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)
$
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.