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.

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).

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.

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

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.

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.

This article has been dead for over six months. Start a new discussion instead.