|
-
Feb 25th, 2010, 04:33 PM
#1
Thread Starter
Addicted Member
Arguments in NetBeans 5.5
Okay, so after programming with VB for a year or two, i figured it's about time i learn another language. One of the beginner examples deals with arguments. Here's the code:
class BlankFiller {
public static void main(String[] args) {
System.out.println("The " + args[0]
+ " " + args[1] + " fox "
+ "jumped over the "
+ args[2] + " dog."
);
}
}
What the program should do is fill in the blanks (args).
In the example i'm using, it says to add arguments i must go to: Run -> Set Project Configuration -> Customize. Then, enter "BlankFiller" into the Main Class field. Then in the arguments field enter "retromingent purple lactose-intolerant" Then click okay. I found where to input this information in a different place than described.(probably different version on netbeans). Anyway, i enter the information and i get this error while running the program.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at BlankFiller.main(BlankFiller.java:3)
The book I'm using mentions this error, but the solution is to enter the information in the arguments field as i said i did above. So, i have no idea why this is not working.
-
Feb 26th, 2010, 01:39 AM
#2
Re: Arguments in NetBeans 5.5
The arguments inside the main function are commandline arguments.... (That's what i think.. )... That is, if we pass something to our program, it will be stored in that array....
Check this link:
* http://www.dickbaldwin.com/java/Java032.htm
...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 26th, 2010, 06:15 AM
#3
Re: Arguments in NetBeans 5.5
5.5! that's too old. Anyway, you can go to the default project's "Run" configuration in the project properties. Or click customize on the "default config" runtime After the "Main Class" which specifies the class to hold the main method e.g. BlankFiller in your case. You'll find a box for arguments. arguments are separated by whitespace either a space or a tab it doesn't matter
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Feb 26th, 2010, 05:51 PM
#4
Thread Starter
Addicted Member
Re: Arguments in NetBeans 5.5
I got it to work, but it was by accident. The book says to run it by going to Run -> Run File. But that causing the error. So when i was trying to get it to work i simply clicked the Green arrow to run the program. The Green arrow is the same as going to Run -> Run Main Project.
And yes, i did upgrade to the latest version on NetBeans
-
Feb 26th, 2010, 05:57 PM
#5
Re: Arguments in NetBeans 5.5
Yeah that too works 
When running a file it just runs it doesn't compile other files or look at run-config
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|