rsiddharth
October 18th, 2009, 01:13 PM
I am trying to write my first program ( Java ) in the Geany IDE ( before I was using Netbeans IDE ) , I am able to write and compile the program successfully but when it I try to run ( Execute ) the program , the IDE is giving me errors .
I tried figure this one out by myself by writing a simple program and I found that , the error has something to do with ' packages ' ( I am writing Java code ) .
Here is my inference :
*Whether I give the 'package' name or not the code is getting successfully compiled ,
*When I mention 'package' name in the code , compilation is successful but Execution gives out errors .
*When I don't mention the 'package' name in the code , both compilation and the Execution are successful .
Here is the simple code that I tried to run in geany :
package strings; // package name mentioned . Execution gives error .
/**
* @author siddharth.
*
*/
public class SGP {
public static void main(String[] args) {
System.out.println("My First Program in Geany IDE! . ");
}
}
The Error :
Exception in thread "main" java.lang.NoClassDefFoundError: SGP (wrong name: strings/SGP)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :637)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:277)
at java.net.URLClassLoader.access$000(URLClassLoader. java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 68)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:336)
Could not find the main class: SGP. Program will exit.
Can any one here point out where I am going wrong .
Thank you for your help !
I tried figure this one out by myself by writing a simple program and I found that , the error has something to do with ' packages ' ( I am writing Java code ) .
Here is my inference :
*Whether I give the 'package' name or not the code is getting successfully compiled ,
*When I mention 'package' name in the code , compilation is successful but Execution gives out errors .
*When I don't mention the 'package' name in the code , both compilation and the Execution are successful .
Here is the simple code that I tried to run in geany :
package strings; // package name mentioned . Execution gives error .
/**
* @author siddharth.
*
*/
public class SGP {
public static void main(String[] args) {
System.out.println("My First Program in Geany IDE! . ");
}
}
The Error :
Exception in thread "main" java.lang.NoClassDefFoundError: SGP (wrong name: strings/SGP)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :637)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:277)
at java.net.URLClassLoader.access$000(URLClassLoader. java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 68)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:336)
Could not find the main class: SGP. Program will exit.
Can any one here point out where I am going wrong .
Thank you for your help !