Quote:
Originally Posted by mrynit
One man's rubbush is a nother man's treasure. Errors tell you what is wrong and hopefully where by giving line numbers.
Sounds like your code is bad.
No, I cannot. I see none of your code and subsequently I cannont help you.
Here is a working example of accepting command line arguments. It uses Java 5 Enhanced For Loop to iterate the array of strings.
import java.io.*; public class PrintArgs { public static void main(String[] args) { System.out.println("This is stuff you entered: \n"); for(String myString: args) { System.out.println(myString); } System.out.println("\nEnd of stuff you entered."); } }
C:\>javac PrintArgs.java
C:\>java PrintArgs arg0 arg1 arg2 yar-harg
This is stuff you entered:
arg0
arg1
arg2
yar-harg
End of stuff you entered.
C:\>
|
thanks for the reply mrynit.
This is the error I get after I copy and past your code into a new netbeans class
init:
deps-jar:
Compiling 1 source file to C:\Users\admin\Documents\NetBeansProjects\JavaNode\build\classes
javac: invalid flag: 1
Usage: javac <options> <source files>
use -help for a list of possible options
BUILD FAILED (total time: 0 seconds
f1 help doesn't do much.
here is code I wrote and tried to run:
public class NewClass {
public static void main (String[]args)
{System.out.println("hi" + args[0]);}
}
and I get this error:
init:
deps-jar:
Compiling 1 source file to C:\Users\azhari\Documents\NetBeansProjects\JavaNode\build\classes
javac: invalid flag: 1
Usage: javac <options> <source files>
use -help for a list of possible options
BUILD FAILED (total time: 0 seconds)
do you know how to pass arguments via any other enviornment e.g. j-creater, eclise etc?