Click here to Skip to main content
15,663,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am very new to java please help me

how to pass arguments as text file and integer number in java.

e.g java inputfile 2

1 solution

More or less as you have shown above, except that you do not try to run the .java file. You first need to compile your Java source with the javac command, and then run the class file thus:
java routing inputfile 2

The input parameters are then accessed from the args argument of the main() method. The following code demonstrates the basic functionality:
public static void main(String[] args) {
    if (args.length > 0) {
        System.out.println("Application arguments:");
        for (String argName : args) {
            System.out.format("\t%s%n", argName);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900