Getting NoClassDefFoundError running java on command line

Trying to run a java program from the command line on windows 7. Here's the back file I'm using:

set javahome=C:\progra~1\java\jdk1.6.0_18
set classpath=.;%javahome%;C:\dev\java\ServiceTest\com\roeschter\jsl
set PATH=%PATH%;%javahome%\bin
java -classpath "%classpath%" TelnetEcho

My current directory is c:\dev\java\ServiceTest which contains the compiled file TelnetEcho.class. Here is the full error message:

C:\dev\java\ServiceTest>java -classpath ".;C:\progra~1\java\jdk1.6.0_18;C:\dev\j
ava\ServiceTest\com\roeschter\jsl" TelnetEcho
Exception in thread "main" java.lang.NoClassDefFoundError: TelnetEcho (wrong nam
e: com/roeschter/jsl/TelnetEcho)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TelnetEcho.  Program will exit.
opikeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

opikeAuthor Commented:
Additional info:

There is a package line in the TelnetEcho.java file -
package com.roeschter.jsl;

I tried having the TelnetEcho.class file in both of the following directories:

C:\dev\java\ServiceTest
&
C:\dev\java\Service\Test\com\roeschter\jsl

But to no avail.
0
CEHJCommented:
You need
set classpath=.;C:\dev\java\ServiceTest

Open in new window

0
opikeAuthor Commented:
I tried adding C:\dev\java\ServiceTest to the classpath but still getting same error. I didn't think it would make a difference since I'm running the java command from C:\dev\java\ServiceTest and that directory is already covered in the classpath with the dot(.).

C:\dev\java\ServiceTest>java -classpath ".;C:\dev\java\ServiceTest;C:\progra~1\j
ava\jdk1.6.0_18;C:\dev\java\ServiceTest\com\roeschter\jsl" TelnetEcho
Exception in thread "main" java.lang.NoClassDefFoundError: TelnetEcho (wrong nam
e: com/roeschter/jsl/TelnetEcho)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TelnetEcho.  Program will exit.
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

CEHJCommented:

java -classpath .;C:\dev\java\ServiceTest com.roeschter.jsl.TelnetEcho

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
opikeAuthor Commented:
Yup I needed to prepend the class name with com.roeschter.jsl.
0
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.