without the .class:

It has to be java HelloCommandLineArguments  ....

this has to be followed by the arguments that you are actually inserting e.g

java HelloCommandLineArguments 2 3 10

you need to omit the .class part

On 8/3/09, David Seto <[email protected]> wrote:
>
>
> Hi Mike
> I ran java HelloCommandLineArguements.class and I still got the same result
>
> -----Original Message-----
> From: Mike Adolf [mailto:[email protected]]
> Sent: Friday, July 31, 2009 6:41 PM
> To: [email protected]
> Cc: [email protected]
> Subject: Re: [java programming] Lab 1038 Command Line Arguements got an
> error message
>
> Hi
>
> Your class is call HelloCommandLineArguments but you execute the
> following to run it.
>
> java HelloCommandLine
>
> I think it should be
> java HelloCommandLineArguments
>
> Mike
>
>
> On Fri, 2009-07-31 at 13:54 -0700, David Seto wrote:
>>
>>
>>
>>
>> Ran the Example –
>>
>> public class HelloCommandLineArguments {
>>
>>     public static void main( String[] args ){
>>
>>         // Print the string "Hello, " on screen
>>         System.out.println("I am saying Hello to the people below..
>> ");
>>
>>         // Check if a command line argument exists
>>         if(args.length == 0)
>>             System.exit(0);
>>
>>         // Display the arguments from the command line
>>         for(int counter = 0; counter < args.length; counter++){
>>             System.out.println("argument index " + counter + ": " +
>> args[counter]);
>>         }
>>     }
>>
>> }
>>
>>
>>
>> After running the javac that created the class then ran the java  I
>> got the following results
>>
>>
>>
>> C:\myjavafxprojects\1038_commandarguments\commandarguments\samples
>> \HelloCommandLineArguments\src>java HelloCommandLine
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> HelloCommandLineArguments/class
>>
>> Caused by: java.lang.ClassNotFoundException:
>> HelloCommandLineArguments.class
>>
>>         at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>
>>         at java.security.AccessController.doPrivileged(Native Method)
>>
>>         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>
>>         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>>
>>         at sun.misc.Launcher
>> $AppClassLoader.loadClass(Launcher.java:301)
>>
>>         at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>
>>         at
>> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>>
>> Could not find the main class: HelloCommandLineArguments.class.
>> Program will exit.
>>
>>
>>
>> >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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