Hi, Im new in this forums looking for an answer for my problem, I find a similar post here so I decided to suscribe here because this website look very professional.

I had the following code:

public class Gen {

	public static void main(String[] args){
		args = new String[6];
		args[0]="0101";
		args[1]="1";
		args[2]="10.10.2.66";
		args[3]="TestDB";
		args[4]="root";
		args[5]="";
		preLoad(args, null);
		System.out.println(errors);
	}
....

My error happens when I run my class file,

[root@localhost classes]# java Gen
Exception in thread "main" java.lang.NoClassDefFoundError: Gen
Caused by: java.lang.ClassNotFoundException: Gen
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Gen.  Program will exit.

I dont know why, but I run the same file on a windows enviroment using JCreator and it runs perfectly, what should be wrong?

Have you compiled Gen.java yet with 'javac'?

yes ...hmm thankyou I found an alternative code javac -d $CLASSPATH Gen.java

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.