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)
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 ]
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:
Yes, that's the path separator ( ; ) followed by point ( . )
[ August 24, 2003: Message edited by: Barry Gaunt ]
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 ]
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.
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.
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 ]
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.
Next it told me to add the J2SDK1.4.0 tag below:
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:
So all together it looks like this:
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!