What's wrong with this program?
First_Cup.java
----------------------------------------------------------------------------
import java.awt.Rectangle;
public class First_Cup {
public static void main(String[] args){
Rectangle cerealBox = new Rectangle(5,10,20,30);
cerealBox.translate(15,25);
System.out.println(cerealBox);
System.out.println("First Cup!");
}
}
I could compile this program successfully; but the byte code could not possibly run.
I have no idea why it could not run. Could somebody tell me why?
Runtime Error Message:
Exception in thread "main" java.lang.NoClassDefFoundError: First_Cup/class
Could not find the main class: First_Cup.class. Program will exit.
Re: What's wrong with this program?
I bet you tried to run it as
Code:
java First_Cup.class
Don't do that and read the tutorials how you are supposed to run your class.
kind regards,
Jos
Re: What's wrong with this program?
I have run the command already; yet it still does not work.
Re: What's wrong with this program?
Quote:
Originally Posted by
java_aim
I have run the command already; yet it still does not work.
"does not work" is not a very detailed problem description.
Jos
Re: What's wrong with this program?
The newly received message:
Exception in thread "main" java.lang.UnsupportedClassVersionError: First_Cup : Unsupported major.minor version 51.0
...
Could not find the main class: First_Cup. Program will exit.
Re: What's wrong with this program?
Quote:
Originally Posted by
java_aim
The newly received message:
Exception in thread "main" java.lang.UnsupportedClassVersionError: First_Cup : Unsupported major.minor version 51.0
...
Could not find the main class: First_Cup. Program will exit.
Type this:
Code:
javac -version
java -version
and show us the results; I suspect that you're using different versions for compilation and running the stuff.
kind regards,
Jos
Re: What's wrong with this program?
Re: What's wrong with this program?
Quote:
Originally Posted by
java_aim
Sorry. It's just worked.
Care to explain what you did to fix it?
kind regards,
Jos
Re: What's wrong with this program?
I just reinstalled JDK. :D (1.7)