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.
Hi!Guys,
I downloaded the latest Java SDK and installed it in my /usr/downloads folder without any problems.When I make my java file I compile it without any problems but when I try to run it with the java HelloWorld.java command I get a "class not found" error what could be the problem.
I know that to run a java class you don't put ".java" I've already programmed in java but in the windows environment.I'm guessing that the class cannot be found coz even in windows when try running a class file that doesn't exist you get an error that goes like this:
"Exception in thread "main" java.lang.NoClassDefFoundError:"
which is the error I'm getting yet the class file exists in my Linux environment.
Only thing I can think of if you are in the same directory and have compiled it okay is you have named the actual filename.java differently from the class that it holds
ie. you've saved it as MyClass.java
when the actual class has been defined as
public myclass
{
}
sort of thing, or named it something completely different
How did you installed? RPM or self-extracting.
If rpm, just use the normal rpm uninstall method.
If self-extraction, just delete the directory, that's it.
I recommand you use self-extraction package.
You can choose to download rpm or self-extraction on the sun website.
It's easier and it can easily put the directory wherever you want, just as a standalone. And give the PATH to the "YourJDKDirectory/bin".
And it can easily co-exist with several version. You don't need to remove the old version. Just put the new one beside and change the PATH, that's it.
To import swing, swing is in the "javax" package. Not in the "java" package.
Like this.
import javax.swing.*
Last edited by moeminhtun; 08-06-2003 at 10:38 AM.
Hi!,
I know that in windows you set the environment variable so that you can compile and run java apps from any directory,Can the same thing be done in Linux?
If it can like share it with guys like me who are trying to shake off the addiction to windows
You have to set your PATH env. variable to include the Java binaries. To see your current path type "echo $PATH" in a terminal, to add Java, type "export PATH=$PATH:/your/path/to/java/bin" or add the line to your ~/.bashrc
You should also make sure that you have your $CLASSPATH variable set before you run, and that this contains the path to both the java classes (rt.jar) and to your own classes.
Remember compiling and running apps depend on different environment variables.
$PATH simply lets you execute the java binaries from any location, however $CLASSPATH tells the Java VM where to look for the classes to execute.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.