Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects (Retired) Delivering the MVP Arrays and Command Line Arguments

Manish Giri
Manish Giri
16,266 Points

How to get args[0] to work in an IDE?

I'm using an IDE(IntelliJ) and apparently the args command doesn't work. I used Game game = new Game(args[0]), but doing so, it went to the if block instead and exited the application.

Since I'm not using the command line to run the application, I cannot enter arguments like the way it's done in the video. How can I make it work in the IDE?

Timothy Boland
Timothy Boland
18,237 Points

Hi Manish...Did you solve the problem?

1 Answer

Athanasios Kourtzis
Athanasios Kourtzis
6,437 Points

In the menu Run you click on Edit Configurations... . In the text field "Program arguments" you simply type your arguments. The first argument will be args[0].

Hope this helps.