📅  最后修改于: 2023-12-03 15:15:57.562000             🧑  作者: Mango
Sometimes you may need to run a Java application in a jar file with some command line arguments for customization or configuration. Here's how you can do it.
cd /path/to/jar/file/
java -jar jarfilename.jar arg1 arg2 arg3...
Here, jarfilename.jar
is the name of your jar file, and arg1 arg2 arg3...
are the command line arguments you want to pass to your application. You can pass as many arguments as you want, but make sure to separate them with spaces.
For example, let's say you have a jar file named myapp.jar
, and you want to pass three arguments arg1
, arg2
, and arg3
. You should run the following command:
java -jar myapp.jar arg1 arg2 arg3
By following these simple steps, you can easily run your Java application in a jar file with command line arguments. It's a straightforward way to customize or configure your application without modifying the source code.