Results 1 to 3 of 3
  1. #1
    Rambar is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default 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
    Java Code:
    import java.util.*;
    class Suma{
     public static void main(String args[]){
      Scanner a = new Scanner(;
      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:
    Java Code:
    santiago@Samorost:~/Java$ java Suma.class
    Exception in thread "main" java.lang.NoClassDefFoundError: Suma/class
    Caused by: java.lang.ClassNotFoundException: Suma.class
    	at Method)
    	at java.lang.ClassLoader.loadClass(
    	at sun.misc.Launcher$AppClassLoader.loadClass(
    	at java.lang.ClassLoader.loadClass(
    	at java.lang.ClassLoader.loadClassInternal(
    Could not find the main class: Suma.class. Program will exit.
    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. ;)

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Rep Power


    Welcome to Java forum!!!!!!!

    when u run take out .class.Go thru sun site for understanding fundas.
    java Suma

  3. #3
    Rambar is offline Member
    Join Date
    Oct 2009
    Rep Power


    Oh damn! I'm feeling stupid right now!

    Thanks for the help, I am impressed by the quickness of the reply. But I should have checked Sun site first, I apologize.

Similar Threads

  1. Netbeans newbie question on compiling
    By DaFlake in forum NetBeans
    Replies: 4
    Last Post: 07-30-2009, 08:04 PM
  2. Basic question on OOP.
    By madthinker in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 08:09 PM
  3. Basic question about EJB
    By javaplus in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-15-2008, 06:44 PM
  4. Very basic question
    By gvi in forum New To Java
    Replies: 2
    Last Post: 10-30-2007, 07:30 PM
  5. basic question about files
    By oregon in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 03:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts