I am trying to run a small java program in command-line but it doesnt work.
class CommandLineArguments{
public static void main (String args[]){
System.out.println("args.length = " + args.length);
System.out.println("args[0] = " + args[0]);
System.out.println("args[1] = " + args[1]);
System.out.println("args[2] = " + args[2]);
}
}
In cmd i go to c:\java the folder i have the .java file in. when i type c:\java%26gt;javac CommandLineArguments.java i get "javac" is not recognized as a command. When i run the c:\java%26gt;java CommandLineArguments 2 4 abcde and i get an error
Exception in thread "main" java.lang.NoClassDefFoundError: CommandLineArguments
can anyone please explain to me how to construct the folder so that i can run this program.
Command-line argument for java?
The folder with the java compiler executable, javac.exe, isn't in your path. In my environment, it's in c:\Program Files\Java\jdk_1.6.0_01\bin. But I always use the NetBeans development environment, which is free. Google it to download the latest version.
Reply:I believe that sometimes the java files must be in the same folder as the javac command in the jdk(?) package.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment