Exception in thread "main" java.lang.NoClassDefFoundError: /root/malla/as/c

Hi,

I am strugling with this for past two days.. Please help me. I am trying to install java on my linux fedora core 2.. It installationis ok.. when I run simple program i am getting the above error.. Please help me.

Exception in thread "main" java.lang.NoClassDefFoundError: /root/malla/as/class

Here is the detals.

Jdk version j2sdk-1_4_2_04-nb-3_6-bin-linux.bin

I installed java in /opt/java here is my path and classpath

JAVA_HOME=/opt/java

CATALINA_HOME=/usr/local/tomcat

PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:/sbin:/usr/sbin

CLASSPATH=$CATALINA_HOME/bin/bootstrap.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/classes:$JAVA_HOME/jre/lib/rt.jar:$CATALINA_HOME/common/lib/servlet.jar:/usr/local/pgsql/share/java/postgresql.jar:../lib/struts.jar:.:./

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CATALINA_HOME CLASSPATH

I put my program in /root/malla

compile is ok but when run the program it is giving the error..

this is my simple program

/* this is a simple Java program */

class as {

// your program begins with a call to main()

public static void main(String args[]){

System.out.println("thi redy fdjljflsdajlfkjaslfjasldasldjfs is a simple Java program");

}

}

I tryed to include package root.malla; and I placed this directory in classpath like /root/malla is also giving same problem.

is there any problem with fedora 2.. Please share your experienc.. who worked with fedora 2. I will thakful to you.

Exception in thread "main" java.lang.NoClassDefFoundError: /root/malla/as/class

[1654 byte] By [chmallareddy1] at [2007-9-30 18:46:06]
# 1

First of all, your classpath looks very weird. You don't need to put the standard Java classes/jars in your classpath, they are included automatically, so lose everything starting with $JAVA_HOME/ from your classpath. Also, you have a few relative path in there (../lib/struts.jar) that won't work unless you are in the right directory. Make it an absolute path.

You have "." (the current directory) in your classpath which is useful only if you are actually in a directory where there are classes (or the start of a package tree)so you can only succesfully run your current program from /root/malla.

However, most importantly, it looks like you try to specify a filename on the commandline where you should be providing the fully qualified classname.

For a class called "as", you just call 'java as' from /root/malla.

One other comment: by convention, Java classnames are in CamelCase (i.e. classnames start with a capital letter and each word in the name is capitalized as well). You class should be called "As" (and reside in a file named As.java).

Herko_ter_Horst at 2007-7-6 21:01:34 > top of Java-index,Administration Tools,Sun Connection...