Anton!

One important point I want to mention in addition to my below mail:
If you are specifying any package name inside your java program, you need to 
save your .java file as per your package name. Example, if you have
anton.java.basic as your package then you need to save your file 
SayHello.java inside c:\MyJava\anton\java\basic and the 4th step becomes:
4. Go to c:\MyJava and run the below steps:
    a. MyJavaEnv.bat
    b. javac anton\java\basic\SayHello.java
    c. java anton.java.basic.SayHello

Regards,
Sai.
--------------------------------------------------
From: "Sai Yelisetty" <ysairam...@gmail.com>
Sent: Monday, March 02, 2009 4:04 AM
To: <anton.shay...@gmail.com>; "Free Java Programming Online Training Course 
By Sang Shin" <javaprogrammingwithpassion@googlegroups.com>
Subject: Re: [java programming] Re: Classpath problem (lab 1003)

> Hello Anton!
> Please follow the below steps and test your java program:
> 1. Open notepad and write the below two lines (Assuming you have JDK at 
> c:\JDK1.6):
> set CLASSPATH = .;c:\JDK1.6\lib\tools.jar;c:\JDK1.6\lib\dt.jar;%CLASSPATH%
> set PATH= c:\JDK1.6\bin;%PATH%
> 2. Save the file as "MyJavaEnv.bat" inside a directory c:\MyJava
> 3. Write a new java program ex. SayHello.java and save it inside c:\MyJava
> 4. Go to c:\MyJava and run the below steps:
>    a. MyJavaEnv.bat
>    b. javac SayHello.java
>    c. java SayHello
>
> Regards,
> Sai.
> --------------------------------------------------
> From: "Anton Shaykin" <anton.shay...@gmail.com>
> Sent: Monday, March 02, 2009 1:02 AM
> To: "Free Java Programming Online Training Course By Sang Shin" 
> <javaprogrammingwithpassion@googlegroups.com>
> Subject: [java programming] Re: Classpath problem (lab 1003)
>
>>
>> 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 <bayo...@yahoo.com> 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. <alfred...@gmail.com>
>>> To: Free Java Programming Online Training Course By Sang Shin 
>>> <javaprogrammingwithpassion@googlegroups.com>
>>> Sent: Sunday, March 1, 2009 12:35:22 PM
>>> Subject: [java programming] Re: Classpath problem (lab 1003)
>>>
>>> On Mar 1, 6:48 pm, buli...@msn.com wrote:
>>>
>>>
>>>
>>> > On Mar 1, 6:52 pm, Anton Shaykin <anton.shay...@gmail.com> 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, buli...@msn.com wrote:
>>>
>>> > > > I believe it has not been compiled.
>>>
>>> > > > On Mar 1, 5:11 am, Anton Shaykin <anton.shay...@gmail.com> 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 javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to