The Artima Developer Community
Sponsored Link

Java Answers Forum
Classpath Question

1 reply on 1 page. Most recent reply: Mar 19, 2004 7:00 PM by twc

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Kevin

Posts: 25
Nickname: doublek321
Registered: Jan, 2004

Classpath Question Posted: Mar 19, 2004 1:09 PM
Reply to this message Reply
Advertisement
I'm trying to run a class through the command line. I figured out how to do this if the compiled class isn't part of a package. However, I'm unable to do this if it is. I'm using JDK 1.4.1 by the way.

My java file is called "SpellCheck.java". The "package" it's in is "projsp". Thus, the start of file "SpellCheck.java" looks like this...

package projsp;

My (relevant) classpath is "C:\Kevin\Java Projects;"

I copied the compiled class to directory "C:\Kevin\Java Projects" and to "C:\Kevin\Java Projects\projsp" (just to be safe).

On the command line I tried typing the following 2 things and both returned the same error...
java SpellCheck

java -ea:projsp:SpellCheck

THE ERROR I GET IS THE FOLLOWING...
Exception in thread "main" java.lang.NoClassDefFoundError: SpellCheck (wrong name: projsp/SpellCheck)


twc

Posts: 129
Nickname: twc
Registered: Feb, 2004

Re: Classpath Question Posted: Mar 19, 2004 7:00 PM
Reply to this message Reply
> I'm trying to run a class through the command line. I
> figured out how to do this if the compiled class isn't
> part of a package. However, I'm unable to do this if it
> is. I'm using JDK 1.4.1 by the way.
>
> My java file is called "SpellCheck.java". The "package"
> it's in is "projsp". Thus, the start of file
> "SpellCheck.java" looks like this...
>
> package projsp;
>
> My (relevant) classpath is "C:\Kevin\Java Projects;"
>
> I copied the compiled class to directory "C:\Kevin\Java
> Projects" and to "C:\Kevin\Java Projects\projsp" (just to
> be safe).
>
> On the command line I tried typing the following 2 things
> and both returned the same error...
> java SpellCheck
>
> java -ea:projsp:SpellCheck
>
> THE ERROR I GET IS THE FOLLOWING...
> Exception in thread "main"
> java.lang.NoClassDefFoundError: SpellCheck (wrong name:
> projsp/SpellCheck)


I see two potential problems.
1. Did you mean to type colons? I suspect you need a space between -ea and propjsp and a period between propjsp and SpellCheck. (I'm not familiar with -ea, so I don't know what affect it may have.)

2. Where is your command prompt when you try to run it? If your source code files are in "C:\Kevin\Java Projects\", then the compiled files should end up in "C:\Kevin\Java Projects\projsp", but you will need to run the command prompt while in "C:\Kevin\Java Projects\".

Try java -ea propjsp.SpellCheck from "C:\Kevin\Java Projects\"

Flat View: This topic has 1 reply on 1 page
Topic: Inner Class Question Previous Topic   Next Topic Topic: How come

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use