Java program with startupparameters parameters in eclipse

I just started using eclipse and java, and I'm not used to any of them. I wrote a simple helloworld program, but the next task (school) was to create a program that accepts userinput (from the command line) and responds with the largest number of two. The code I wrote is as follows:

public class Larger {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        if(args.length < 2)
        {
            System.out.print("Too few parameters submitted.");
            return;
        }
        int num1 = Integer.parseInt(args[0]);
        int num2 = Integer.parseInt(args[1]);
        System.out.print(Math.max(num1, num2));
    }

}

Everything works well when I click the run button in eclipse, but later, when I look at the source files and run "java Larger.class 2 4", I get an error message from java.exe saying that the class was not found.

Any idea what this could be?

+3
source share
3 answers

, Java Eclipse ? , . ".class" Java-. :

java Larger 2 4
+2

javac Large.java

java Larger 2 4

0

Source: https://habr.com/ru/post/1728352/


All Articles