Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

My first program after installing. An Error Shows up

Thread view: 
cat_dog_a.s - 06 Jan 2006 04:14 GMT
I've created abc.java file in c:\sun\appserver\jdk\bin.
I've made this my current directory.
I compile by typing at the prompt javac abc.java.
It compiles.
Next i type java abc
I get this error: EXception in thread "main"
java.lang.NoClassDefFoundError: ABC/class
Why does this happen?

My source code is:

class ABC
{
    public static void main(String args[])
    {
        System.out.println("This is the output");
    }
}
Chris Smith - 06 Jan 2006 08:25 GMT
> Next i type java abc
> I get this error: EXception in thread "main"
> java.lang.NoClassDefFoundError: ABC/class

You didn't type "java abc".  Instead, you typed "java ABC.class".  
Neither is correct.  You should have typed "java ABC".

In the future, it will probably be easier to help you with your problems
if you don't lie about them.
Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

zero - 06 Jan 2006 16:30 GMT
> I've created abc.java file in c:\sun\appserver\jdk\bin.

You shouldn't story your own code in the java bin directory.

Since you're obviously new to Java, I suggest starting with J2SE, not the
Sun application server.

http://java.sun.com/j2se/1.5.0/download.jsp
pick the "JDK 5.0" download

> I've made this my current directory.
> I compile by typing at the prompt javac abc.java.
> It compiles.

Java is case sensitive.  public class ABC must be stored in file
ABC.java, not abc.java.  This only compiles because you didn't make class
ABC public.

> Next i type java abc
> I get this error: EXception in thread "main"
> java.lang.NoClassDefFoundError: ABC/class
> Why does this happen?

First have a look at what Chris said.

This happens because there is no class called "class" in package "ABC".  
Instead, there is a (non-public) class called "ABC".

> My source code is:
>
> class ABC

use public class ABC instead

> {
>      public static void main(String args[])
>      {
>           System.out.println("This is the output");
>      }
> }

Signature

Beware the False Authority Syndrome



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.