Eclipse: Run Java Program with CLI Arguments
Date: 2015-09-29 |
**Problem: **I have a Java program that takes in command line arguments, but I want to compile and run it using Eclipse. How do I run it with command line arguments from within Eclipse?
**Solution: **Using Eclipse, you can modify the arguments being passed into your program by configuring the Run option for each file in your project. To modify the Run configuration for a program:
- Click Run > Run Configurations…
- On the left side, find and select the program you want to add arguments for.
- Click on the Arguments tab.
- In the Program Arguments field, type in the arguments exactly as they would be input into the command line (exclude the javac/java commands that would normally accompany a Java program call from the CLI).
- Click Run. This will compile and run the current program with the given args. After running the program, this configuration will be saved for future runs of the same program, so be sure to change it if you need to.
Want more like this?
The best / easiest way to support my work is by subscribing for future updates and sharing with your network.