With the -cp argument you provide the classpath i.e. path(s) to additional
classes or libraries that your program may require when being compiled or
run.

dot after -cp sets classpath on current directory.

You would get same result with setting "set CLASSPATH=", not "set
CLASPATH=something". ;) You should check your environment variable, because
is pointing somwhere else for sure.


2014-02-11 14:50 GMT+01:00 Jaya Penugonda <[email protected]>:

>  "MyJavatrainingPrograms> java -cp . Hello" worked and I got the results.
>
>
> Here is what I got.
>
> c:\MyJavatrainingPrograms>java -cp . Hello
>
> Hello world
>
> This is my first Java program!
>
>
>
> What does '-cp' mean here?
>
>
>
> Thanks for the help.
>
> Jaya
>
>
>
> On Tue, Feb 11, 2014 at 7:42 AM, Jaya Penugonda 
> <[email protected]>wrote:
>
>>
>> Yes, this folder has both Hello.java and Hello.class files. Please see
>> the attached screenshot.
>>
>> --Jaya
>>
>> On Tue, Feb 11, 2014 at 6:28 AM, sumanth keith <[email protected]>wrote:
>>
>>> Hi Jaya,
>>>
>>> The problem is with your CLASSPATH
>>>
>>> try this:
>>>
>>> your MyJavatrainingPrograms folder should contain your Hello.java and
>>> Hello.class files
>>>
>>> c:\MyJavatrainingPrograms> java -cp . Hello
>>>
>>>
>>> On Tue, Feb 11, 2014 at 5:37 PM, Paweł Skarżyński <
>>> [email protected]> wrote:
>>>
>>>> Did you try executing this command: "set CLASSPATH=" before compiling
>>>> and running program?
>>>>
>>>>
>>>> 2014-02-11 13:04 GMT+01:00 Jaya Penugonda <[email protected]>:
>>>>
>>>> C:\MyJavatrainingPrograms---This is where I have saved my "Hello" file.
>>>>>
>>>>>
>>>>> On Tue, Feb 11, 2014 at 5:56 AM, Jaya Penugonda <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> HI,
>>>>>>
>>>>>> I did get the response when I tried the java and javac commands.
>>>>>> Please see the attached.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Tue, Feb 11, 2014 at 1:02 AM, Murali Reddy <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I think You dint set the java path in environment .
>>>>>>>
>>>>>>> Make sure you get a proper response when you try using the commands
>>>>>>> "java"  and "javac" as shown in attachment .
>>>>>>>
>>>>>>> If you dint get any response , then set the path for java home in
>>>>>>> the environment variable.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>> Muralidhar
>>>>>>>
>>>>>>> On Tue, Feb 11, 2014 at 12:16 PM, Paweł Skarżyński <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> It may be a classpath problem. Try this command before running java:
>>>>>>>> set CLASSPATH=
>>>>>>>>
>>>>>>>> ... and paste the content of your source file.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2014-02-11 0:16 GMT+01:00 Jaya <[email protected]>:
>>>>>>>>
>>>>>>>> I am getting the following error. What am I missing here?
>>>>>>>>>
>>>>>>>>>  Directory of c:\MyJavatrainingPrograms
>>>>>>>>>
>>>>>>>>>  02/07/2014  12:27 PM    <DIR>          .
>>>>>>>>>
>>>>>>>>> 02/07/2014  12:27 PM    <DIR>          ..
>>>>>>>>>
>>>>>>>>> 02/07/2014  12:27 PM               415 Hello.class
>>>>>>>>>
>>>>>>>>> 02/07/2014  12:27 PM               187 Hello.java
>>>>>>>>>
>>>>>>>>>                2 File(s)            602 bytes
>>>>>>>>>
>>>>>>>>>                2 Dir(s)  201,567,584,256 bytes free
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> c:\MyJavatrainingPrograms>java Hello
>>>>>>>>>
>>>>>>>>> Exception in thread "main" java.lang.NoClassDefFoundError: Hello
>>>>>>>>>
>>>>>>>>> Caused by: java.lang.ClassNotFoundException: Hello
>>>>>>>>>
>>>>>>>>>         at java.net.URLClassLoader$1.run(Unknown Source)
>>>>>>>>>
>>>>>>>>>         at java.security.AccessController.doPrivileged(Native
>>>>>>>>> Method)
>>>>>>>>>
>>>>>>>>>         at java.net.URLClassLoader.findClass(Unknown Source)
>>>>>>>>>
>>>>>>>>>         at java.lang.ClassLoader.loadClass(Unknown Source)
>>>>>>>>>
>>>>>>>>>         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>>>>>>>> Source)
>>>>>>>>>
>>>>>>>>>         at java.lang.ClassLoader.loadClass(Unknown Source)
>>>>>>>>>
>>>>>>>>> Could not find the main class: Hello.  Program will exit.
>>>>>>>>> Thanks,
>>>>>>>>> Jaya
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, February 7, 2014 12:31:08 PM UTC-6, Jaya wrote:
>>>>>>>>>>
>>>>>>>>>> Thanks for the help. I am not sure what \8220 or \8221 are but I
>>>>>>>>>> just removed the quotes and added again, It is working fine now.
>>>>>>>>>> --Jaya
>>>>>>>>>>
>>>>>>>>>> On Thursday, February 6, 2014 11:33:10 PM UTC-6, Jaya wrote:
>>>>>>>>>>>
>>>>>>>>>>> I am getting the following error. Can you please tell me what is
>>>>>>>>>>> missing?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> c:\MyJavatrainingPrograms>javac Hello.java
>>>>>>>>>>>
>>>>>>>>>>> Hello.java:7: illegal character: \8220
>>>>>>>>>>>  System.out.println(ôHello worldö);
>>>>>>>>>>>                     ^
>>>>>>>>>>> Hello.java:7: ';' expected
>>>>>>>>>>>  System.out.println(ôHello worldö);
>>>>>>>>>>>                      ^
>>>>>>>>>>> Hello.java:7: illegal character: \8221
>>>>>>>>>>>  System.out.println(ôHello worldö);
>>>>>>>>>>>                                 ^
>>>>>>>>>>> Hello.java:7: not a statement
>>>>>>>>>>>  System.out.println(ôHello worldö);
>>>>>>>>>>>                            ^
>>>>>>>>>>> 4 errors
>>>>>>>>>>>
>>>>>>>>>>> c:\MyJavatrainingPrograms>
>>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "JPassion.com: Java Programming" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to [email protected].
>>>>>>>>> Visit this group at http://groups.google.com/group/jpassion_java.
>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "JPassion.com: Java Programming" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> Visit this group at http://groups.google.com/group/jpassion_java.
>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "JPassion.com: Java Programming" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> Visit this group at http://groups.google.com/group/jpassion_java.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to