954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

beginners help!

I am in java programing this year in college. First couple of chapters have went fine. They have us learning by using "notepad" and the command prompt. I had just completed my latest assignment and went to compile it and it told me "class or interface expected". I figured I did something wrong. I went and retrieved another assignment that I have already ran know it works. It compiled fine, but when I try to run it gives me "java.lang.noclassdeffounderror". I tried other assignments that I knew were wright, and they say the same thing. Any help will be greatly appreciated.

ATS
Light Poster
41 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 

Check your classpath settings. Most likely you don't have the current directory ('.') in your classpath.
Or if not that, you have a typo somewhere in your classname (remember Java is case sensitive) or you're in the wrong directory (and the directory your classes root in is not in the classpath).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

when u are running the programm. remember this
u should use
c:\>java (classname which contains main method)
do not type the .java extension when running the file.`
u shud use it only wen u are compiling.

indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
 

I have checked my enviromental paths and the all check out ok. I tried to run the first program i created for my class. I know this program runs because I checked before I turned it in. THis is the process I use to run the program.

"javac lab1a.java"
I get a clean compile and then input
"java lab1a" after I hit enter it displays
"Exception in thread "main" java.lang.NoClassDefFoundError: lab1a"

just a though, could a virus cause me any problems when trying to run an app? Thanks for your help

ATS
Light Poster
41 posts since Jun 2006
Reputation Points: 10
Solved Threads: 1
 
I have checked my enviromental paths and the all check out ok. I tried to run the first program i created for my class. I know this program runs because I checked before I turned it in. THis is the process I use to run the program. "javac lab1a.java" I get a clean compile and then input "java lab1a" after I hit enter it displays "Exception in thread "main" java.lang.NoClassDefFoundError: lab1a" just a though, could a virus cause me any problems when trying to run an app? Thanks for your help

first off all please post the source code here.
ok.... just after compiling and before running, u try to search for lab1a.class file in the same directory.
if u do not find it i am afraid the java runtime environment or the JVM is not configured properly.
try reinstalling the JDK.

regarding ur last doubt. the answer is no.
a general virus cannot prevent the execution (running) of a java program normally.

indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
 

moreover there is another chance that the class file is getting saved somewhere else. so search for it and copy paste it in the directory which u have set as the class path.
then run ur program by using the java lab1a command.

indianscorpion2
Junior Poster in Training
82 posts since May 2005
Reputation Points: 9
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You