# Newbee question how to use JUCEApplication::getCommandLineParameterArray()

**URL:** <https://forum.juce.com/t/newbee-question-how-to-use-juceapplication-getcommandlineparameterarray/32829>\
**Category:** Windows\
**Created:** [April 12, 2019, 11:03am UTC](https://forum.juce.com/t/newbee-question-how-to-use-juceapplication-getcommandlineparameterarray/32829 "2019-04-12T11:03:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benvos](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@benvos](https://forum.juce.com/u/benvos)\
**Post date:** [April 12, 2019, 11:03am UTC](https://forum.juce.com/t/newbee-question-how-to-use-juceapplication-getcommandlineparameterarray/32829/1 "2019-04-12T11:03:42Z")

</div>

I want to use getCommandLineParameterArray() in my Gui application. But I alway’s get an empty array.

So I created a new console application just to test;

#include “…/JuceLibraryCode/JuceHeader.h”  
#include

//==============================================================================  
int main (int argc, char\* argv)  
{

```
std::cout << "argc =" << String(argc) << "\n";
for (int i = 0; i < argc; ++i) {
	std::cout << "argv param " << String(i) << " = " << argv[i] << "\n";
}

std::cout << "\nCommandline = " << JUCEApplication::getCommandLineParameters();

StringArray commandline = JUCEApplication::getCommandLineParameterArray();
std::cout << "\nCommandline params = " << String(commandline.size()) << "\n\n";
for (int i = 0; i < commandline.size(); ++i) {
	std::cout << "Commandline param " << String(i) << " = " << commandline[i] << "\n";
}

return 0;

```

}

When I start it with “ **test.exe This is a test -h** ”  
The output is:  
_argc =6_  
_argv param 0 = test.exe_  
_argv param 1 = This_  
_argv param 2 = is_  
_argv param 3 = a_  
_argv param 4 = test_  
_argv param 5 = -h_

_Commandline =_  
_Commandline params = 0_

What am I doing wrong? And what is the best way to access command-line parameters in a Gui application?

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [April 12, 2019, 3:16pm UTC](https://forum.juce.com/t/newbee-question-how-to-use-juceapplication-getcommandlineparameterarray/32829/2 "2019-04-12T15:16:54Z")

</div>

You have to use the JUCEApplication class to make use of that API. Check out the basic GUI app tutorial: [https://docs.juce.com/master/tutorial\_main\_window.html](https://docs.juce.com/master/tutorial_main_window.html)

---

<div class="post-metadata">

**Author:** ![benvos](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@benvos](https://forum.juce.com/u/benvos)\
**Post date:** [April 12, 2019, 7:54pm UTC](https://forum.juce.com/t/newbee-question-how-to-use-juceapplication-getcommandlineparameterarray/32829/3 "2019-04-12T19:54:05Z")

</div>

Thank you. I got it working now.
