Results 1 to 6 of 6
Thread: Command-Line Arguments
- 02-23-2010, 12:18 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 33
- Rep Power
- 0
Command-Line Arguments
on one example program it says to put a command line argument to see the program run and i dont know where to put it?
do you have to write it in the code?
Java Code:class YearDisplayer { public static void main(String[] arguments) { int year = 2000; if (arguments.length > 0) year = Integer.parseInt(arguments[0]); for (int month = 1; month < 13; month++) for (int day = 1; day <= countDays(month, year); day++) System.out.println(month + "/" + day + "/" + year); } static int countDays(int month, int year) { int count = -1; switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: count = 31; break; case 4: case 6: case 9: case 11: count = 30; break; case 2: if (year % 4 == 0) count = 29; else count = 28; if ((year % 100 == 0) & (year % 400 != 0)) count = 28; } return count; } }
-
If you call YearDisplayer on the command line with the java command, put the arguments there:
java YearDisplayer argument1 argument2
- 02-23-2010, 02:23 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Are you working on command prompt or on an IDE? Different IDEs have different techniques to assign command line parameters, but the concept is the same.
- 02-25-2010, 11:54 PM #4
Member
- Join Date
- Dec 2009
- Posts
- 33
- Rep Power
- 0
If you call YearDisplayer on the command line with the java command, put the arguments there:
and I am using Eclipse
-
If you're using Eclipse, then it's buried in Eclipse, but you can find it by going to the run menu and searching for it under Run Configurations, then Program Arguments.
- 02-26-2010, 03:13 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Similar Threads
-
java command line arguments
By Vipul03 in forum Advanced JavaReplies: 10Last Post: 02-25-2010, 10:12 AM -
Command Line Arguments
By Nakira in forum NetBeansReplies: 10Last Post: 02-04-2010, 03:45 PM -
arguments in command-line
By girlet18 in forum New To JavaReplies: 2Last Post: 01-21-2010, 02:05 PM -
Command line arguments help
By may88 in forum New To JavaReplies: 8Last Post: 12-08-2009, 01:20 PM -
[SOLVED] command line arguments using IDE
By sandeepsai39 in forum New To JavaReplies: 5Last Post: 03-12-2009, 07:19 AM
Bookmarks