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\HelloComm
andLineArguments\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