background
What kind of processing is done when a Java command is executed in the first place in business?
I looked it up.
--The java command is a command to start the JVM --The JVM loads the specified class after startup and calls the class's main method -** java command syntax **
java fully qualified class name[Argument argument...]
--The arguments that follow the class name are called ** "startup parameters" ** or ** "command line arguments" **. --Multiple startup parameters can be specified by separating them with a space. --Startup parameters are optional and can be omitted --The data specified as the startup parameter is stored in the String array object by the JVM and passed as an argument of the main method.
--Launch the JVM --Find and load the specified class from the classpath --Create a String type array object to store startup parameters --Execute the main method with a reference to the String array type object that holds the startup parameters as an argument.
public class Main{
public static void main(String[] args) {
System.out.println(args[0] + " " + args[1]);
}
}
command
$ java Main red blue grenn
[Dokojava](https://www.google.com/url?sa=t&rct=j&q=1esrc=s&source=web&cd=1cad=rja&uact=8&ved=2ahUKEwj5qq3KlMPsAhWlIqYKHcW1Cl4QFjAAegQIARAC&url=https%3AgQIARAC&url=https Let's actually try it with iJ_00k-0ctsUdsFTbwDe)!
[Even beginners can easily understand] Summary of how to use java commands
Recommended Posts