Hi David, 

all you need to do is run: 

    java HelloCommandLineArguments   (do not the use .class extension - that is 
what is causing the error) 



Regards, 
Dean Rush   


----- Original Message ----- 
From: "David Seto" <[email protected]> 
To: [email protected] 
Sent: Monday, August 3, 2009 5:42:26 PM GMT -05:00 US/Canada Eastern 
Subject: RE: [java programming] Re: Lab 1038 Command Line Arguements got an 
error         message 




Hi Dean 

This is what I did – 

Javac HelloCommandLineArguments.java to compile which worked fine. It created 

HelloCommandLineArguments.class 

I then typed in java HellocommandLineArguments.class 

Then I got the error message listed previously. 





From: [email protected] 
[mailto:[email protected]] On Behalf Of Dean Rush 
Sent: Monday, August 03, 2009 2:34 PM 
To: [email protected] 
Subject: [java programming] Re: Lab 1038 Command Line Arguements got an error 
message 



David, to compile the command should be: 

    javac HelloCommandLineArguments.java 



To run: 

    java HelloCommandLineArguments 




Regards, 
Dean Rush   










From: [email protected] 
[mailto:[email protected]] On Behalf Of David Seto 
Sent: Monday, August 03, 2009 5:07 PM 
To: 'Babu Rajendran' 
Cc: [email protected] 
Subject: [java programming] Re: Lab 1038 Command Line Arguements got an error 
message 

Sorry for the typo – 

I meant I typed in Java HelloCommandLineArguements.java 

It created the class. 

Then typed in javac HelloCommandLineArguements.class 

Then got the error message listed below 

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. 




From: Babu Rajendran [mailto:[email protected]] 
Sent: Friday, July 31, 2009 9:05 PM 
To: [email protected] 
Cc: [email protected] 
Subject: Re: [java programming] Lab 1038 Command Line Arguements got an error 
message 



Hi David, 

The name of your class is HelloCommandLineArguments and not HelloCommandLine . 
Hence you should run your program as: 

c:\myprograms>java HelloCommandLineArguments 

Regards, 
Babu 


On Sat, Aug 1, 2009 at 2:24 AM, David Seto < [email protected] > 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. 







<BR 

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