Thank you, that's actually what I did after nothing helped. So is
there no way to set classpath using only command line? As I see it
sets classpath only for one session, but it doesn't work even this
way. I mean when I type "set classpath = C:\Java Programs\Classes" it
seems to work, and then I type "set classpath" and it displays
"classpath = C:\Java Programs\Classes", and everything looks just
fine, but when I try "java Hello" it doesn't work! I know that it
works perfectly the way you described, but again, the question is "How
can I do the same using command line".
Thank you.

On Mar 1, 10:00 pm, Samuel Abiodun <[email protected]> wrote:
> It appears your set CLASSPATH is good for the session you ran your  "java 
> Hello" program. The following steps will set your path  permanently and 
> you'll be able to run java  program from any directory of your Windows 
> machine.
>
> 1. Start --> Control Panel --> System --> Advanced tab
> 2. Click Environment Variables
> 3. Select CLASSPATH and click Edit
> 4. In Edit System Variable Dialog box, Enter .; (dot semicolon) as the first 
> entry in Variable Value.
> 5. Add complete path to jdk e.g. "C:\Program Files\JavaStuff\jdk1.6\bin"
> 6. Click Ok and exit
> 7. Launch a new command prompt
> 8. Test by typing "echo "CLASSPATH" you should see.; and path to your jdk
> 9. Running your program from any directory should be fine.
>
> Samuel Abiodun
>
> ________________________________
> From: Alfred H. <[email protected]>
> To: Free Java Programming Online Training Course By Sang Shin 
> <[email protected]>
> Sent: Sunday, March 1, 2009 12:35:22 PM
> Subject: [java programming] Re: Classpath problem (lab 1003)
>
> On Mar 1, 6:48 pm, [email protected] wrote:
>
>
>
> > On Mar 1, 6:52 pm, Anton Shaykin <[email protected]> wrote:> Please 
> > take a look at this picture:
> > > [url=http://www.freeimagehosting.net/][img]http://www.freeimagehosting.net/uploads/e152ac2528.jpg[/img][/url]
> > > I tried everything, but it doesn't work. And I believe I shouldn't be
> > > currently in "C:\Java Programs\Classes" directory to run the class,
> > > because if so, why setting CLASSPATH variable at all? I believe the
> > > only value of doing so is a possibility to run your programs, no
> > > matter what directory you're currently in. Am I wrong?
>
> > I believe so too. My Hello runs fine in another directory. Perhaps you
> > could specify the classpath explicitly like this:
> > C:\Java Programs\Sources>java -cp ..\classes Hello
>
> > > Another issue is that I don't see CLASSPATH in the list of
> > > enviromental variables, is it OK (see picture attached)?
> > > [url=http://www.freeimagehosting.net/][img]http://www.freeimagehosting.net/uploads/49d954a64e.jpg[/img][/url]
> > > Thanks for any help!
>
> > > On Mar 1, 6:10 am, [email protected] wrote:
>
> > > > I believe it has not been compiled.
>
> > > > On Mar 1, 5:11 am, Anton Shaykin <[email protected]> wrote:> 
> > > > After successfully setting up classpath using
> > > > > set CLASSPATH = C:\Java Programs\Classes
> > > > > and putting .class file into that directory I still get an exception
> > > > > java.lang.NoClassDefFoundError
> > > > > What could be the possible solution?
> > > > > Even after typing "set CLASSPATH" I see exactly this directory
> > > > > displayed. And I'm positive there's a Hello.class file in it. But
>
> > > > You can confirm it is there at cmd by:
> > > > C:\Java Programs\Classes>dir
>
> > > > > every time I type "java Hello" I get the same error.
> > > > > Any help?
>
> I think you have to specify the class you have to run. Assume u have 2
> directories in your classpath and both have same file to run but with
> a bit different implementation. JVM has to know which file to run.

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to