• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error Message Exception thread "main" Java.lang.NoClassdef Found Error Hello...?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just started my Java Class this week in college. We were assigned a short program so I downloaded text pad. I am compling and running the program in textpad. I decided to try the following example from the book below.
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello, world");
}
}
This program complied fine but then I tried to run it and I got the No Class Definition message. I have no idea what this means so could someone please give me instructions that aren't quite so technical (because I have never used text pad before)so that I may remedy this problem.
I would appreciate this greatly.
PS I am using Win 98 and my autoexec bat file is running a macaffee virus scan so I don't know how to be able to change the class path file this way.
[ August 23, 2003: Message edited by: Pam Not Available ]
[ August 23, 2003: Message edited by: Pam Not Available ]
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My class path is A:/Chapter1/Hello.java
Is this a class path problem and how do I go about changing it?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch Pam. Please take a little time to read JavaRanch's Naming Policy and change your displayed name accordingly. You can change it here.
Thanks,
-Barry
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As to your original post I suggest you take a look at Sun's Tutorial Introduction. It should answer your question. If not get right on back here .
I just noticed:
You are using forward slashes ( / ) and not backward slashes ( \ ).
You are using drive A: (normally a floppy drive). Really?
The class path should not include the java file itself. For example: C:\Chapter1 is enough.
Usually one includes the current directory on the path like this:
SET CLASSPATH=C:\Chapter1;.
Yes, that's the path separator ( ; ) followed by point ( . )
[ August 24, 2003: Message edited by: Barry Gaunt ]
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry.
Thanks for your help. I have already looked at the First Cup of Java page. My problem is that instead of typing in the commands like javac we use Text pad to run and compile. The reason I am using my floppy drive as a class path is because my professor wants us to save the programs on a floppy. I have tried to go into the autoexec file by doing the Run C:\autoexec it will come up but currently its being used to run a MacAfee virus scan, and won't let me make any changes. If I could make changes I would be afraid to delete the virus scan info. This is my first time using the autoexec bat. So how would I go about making the changes necessary with out losing the Virus Scan stuff?
By the way I am using Win 98 2nd E.
[ August 24, 2003: Message edited by: Pamela Leigh ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Pam, using Textpad, can you get a program to compile and run using the C: drive? If so, all you have to do is use the "Save As" command to put the finished java file on the floppy.
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Barry Gaunt:
Ok Pam, using Textpad, can you get a program to compile and run using the C: drive? If so, all you have to do is use the "Save As" command to put the finished java file on the floppy.[/QUOUTE]
See when I saved it to the floppy it compiled sucessfully but then gave me the above error about the class definition. But I'll try what you suggested. Hopefully, it will work. I'd really like to start working on the first program.
Thanks so much I'll give it a try. Just be sure to check back to my post please. I'll post to let you know if I got a sucess or not.

 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry,
The File Save As Command did not work.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say it does not work, in what way does it not work?
I do not have a floppy drive, so I cannot try it. Did you create the A:\Chapter1 directory before trying to save the file to A:\Chapter1\Hello.java?
[ August 24, 2003: Message edited by: Barry Gaunt ]
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I mean I tried to save it on the C:\ drive and I compiled and ran the program. It compiled fine and then I still got the same error message about No class definition. My only guess is that I have to set the class path now, but as I said it executes Macafee Virus Scan in Autoexec.bat. So I don't know what to do. Hopefully my professor will.
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pamela
You may have tried it before.
Follow the steps in order :
1. Find out where java is installed. (directory would be somewhat like j2sdk1.4.0 for Java SDK 1.4)
2. Goto autoexec.bat, open it and add an entry like

This is in case you have Windows 95, 95 or ME. In case of Windows 2000/XP different steps need to be followed.
3. Before you compile/run any program restart the machine.
4. Make a file like say chapter1.java and save it in the folder "C:\J2SDK1.4.0\BIN\".
5. Compile and run the file. The file should now run.
[b]Pamela : "I have tried to go into the autoexec file by doing the Run C:\autoexec it will come up but currently its being used to run a MacAfee virus scan, and won't let me make any changes."
To edit the autoexec.bat, select autoexec.bat and right-click then choose edit from the menu or from the DOS prompt type

Now in the windows that now opens add the entry specified above, after all the previous line/s.
McAfee virus scan should not be interrupted by this. The autoexec.bat entry for the McAfee specifies that the virus scan should be done beofre the system boots up (By default it scans only the C:\ only) . Most probably your system would be configured so that once the system loads up you will have the McAfee Antivirus running. So that is even if the entry/file is deleted you will still be having McAfee running once windows loads up. But I would suggest that you keep an entry in the autoexec.bat as well. To be sure copy the file with a different name like ae.bat or anything. Then in case you mess up with editing or anything you can again copy back/rename the ae.bat to autoexec.bat.
[ August 24, 2003: Message edited by: Anupam Sinha ]
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
Thank you. I think this may work however, my professor wants my class to save our programs to the Floppy drive A:\. Do I need to make any modifications to the set path for it to do this?
 
Pamela Leigh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I fixed it!
Thank you both so much for your help. I really appreciate it.
A, Your instructions helped my thought process greatly. I ran the autoexec.bat file only to discover edit would mark but it wouldn't let me Add anything to it. So I decided to go to Sun's tutorial, to see if I had missed anything special. I had. With Win 98 users have to Run sysedit from there it allows you to operate the autoexec.bat
So my Macafee was there. Next the instructions told me to find the Path command.
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\MSOFFICE\OFFICE
Next it told me to add the J2SDK1.4.0 tag below:
;C:\J2SDK1.4.0\BIN
but then it couldn't pull any of the bytecode off of my floppy. (My professor wanted me to put it on a floppy disk). So it said I could add another directory with a ; proceeding the directory. So after 10 tries I finally came up with:
;A:\
So all together it looks like this:
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\MSOFFICE\OFFICE;C:\J2SDK1.4.0\BIN;A:\
So I Saved the File and then Rebooted and Started TextPad and it ran my programs!! I am sorry that it took me reading the tutorial again, but guys I want you to know that with your posts it clarified what the Instructions at Sun were saying. So your work wasn't for nothing.
Thank you so much!
 
reply
    Bookmark Topic Watch Topic
  • New Topic