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.
I installed the java JDK and went through a tutorial but when it came to do javac I get command not found. I searched my whole system several different ways and it seems I dont have javac. How do I get it?
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
Quote:
Originally Posted by M$ISBS
I installed the java JDK and went through a tutorial but when it came to do javac I get command not found. I searched my whole system several different ways and it seems I dont have javac. How do I get it?
By installing the JDK, I guess you only installed the JRE (runtime).
You should not need to download a separated JRE. The SDK already has a JRE. The error you are getting is most likely because you don't have java on your path. A quick search in this forum for Java Path will bring some threads. This question is very common and even I have answered it more than once. You could also search google.com for "java path linux" or even at Sun's site there is a tutorial about that.
I won't post any direct links, this is just a simple case of searching...
2. I'll admit that that the instructions can be confusing if you've never done it before. Please feel free to post any follow-on questions to LQ.
3. In your posts, please try to be as SPECIFIC as possible.
For example, cut/paste the filename you're trying to extract (this would give a lot of information: it would tell us whether it's the JRE or the JDK, whether it's an .rpm or a .bin - or even whether it's Sun Java or "something else").
Please, too, cut/paste exact error messages you might be getting.
Thanks for the replies. I found the file javac. I now have a new problem though. When I run java HelloWorldApp, I get these errors:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java
Does this look hard to fix?
I know nothing about java and am just starting out.
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
i made the same filename and pasted your code and tried it (on windows) and it compiled and ran without any messages.
when you use 'javac' to compile you include the '.java' in the filename, when you run it with 'java' you dont include any extension, just 'java HelloWorldApp', is this what your doing?
i made the same filename and pasted your code and tried it (on windows) and it compiled and ran without any messages.
when you use 'javac' to compile you include the '.java' in the filename, when you run it with 'java' you dont include any extension, just 'java HelloWorldApp', is this what your doing?
nadroj:
Yes, thats exactly how I am doing it.
indienick:
I tried that and I get the same error messages as before.
I just tried something different. I logged in as root and tried it, but I had to put ./ in front of javac and java, the long list of errors went away but I still get:
"Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.