Basic question about compiling
Hello! Im starting to learn Java on my spare time (I just realised I dont like Pascal anymore), and I've come across a curious problem.
I've made a simple (very simple!) program under Geany on Linux. Here is the souce
Code:
import java.util.*;
class Suma{
public static void main(String args[]){
Scanner a = new Scanner(System.in);
System.out.println("Dame un número");
int b = a.nextInt();
System.out.println("Dame otro número");
int c = a.nextInt();
System.out.println("La suma de " + b + " y " + c + " es " + (c+b));
}
}
I can compile it and run it succesfuly on Geany. But when I try the manual approach, compiling and running from a terminal, I get this:
Code:
santiago@Samorost:~/Java$ java Suma.class
Exception in thread "main" java.lang.NoClassDefFoundError: Suma/class
Caused by: java.lang.ClassNotFoundException: Suma.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: Suma.class. Program will exit.
santiago@Samorost:~/Java$
That comes after succesfuly compiling the program via javac. To be honest, I dont really know much about linux either. So I'd like if you could explain what went wrong here. Thanks for your help.
PD: By the way, I just joined the forums. I'd also like to say hi to the community. ;)