Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to compile some code written in Java and I used the command:


and I got following errors:

Exception in thread "main" java.lang.NoClassDefFoundError: Code/java
Caused by: java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
Could not find the main class: Program will exit.

I would be thankful for your advice.

share|improve this question
You should be running javac and then java Code. – i08in Apr 3 '14 at 15:34
up vote 2 down vote accepted

The correct way of compiling java code in your case is


and then run using

java Code
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.