learningunix
asked on
parsing command line options in Java
i want to write an application
java -jar TEST.jar -u username -h host etc.....
can someone point me to example of parsing this.
java -jar TEST.jar -u username -h host etc.....
can someone point me to example of parsing this.
http://snippets.dzone.com/posts/show/3504
ASKER
I don't have
import org.apache.commons.cli.*;
Is ther any way without inastalling new java packages?
import org.apache.commons.cli.*;
Is ther any way without inastalling new java packages?
public class Echo {
public static void main (String[] args) {
for (String s: args) {
System.out.println(s);
}
}
}
http://download.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html
public static void main (String[] args) {
for (String s: args) {
System.out.println(s);
}
}
}
http://download.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html
ASKER
I am looking something similar to waht we have in C++ GetOpt
If you organise the args well (as you have) then you should be able to use a Map
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I just downloaded jot-simple.
I'll give it a try and see
so when I create my own jar file do I have to give all class file of jotsimple also ?
I'll give it a try and see
so when I create my own jar file do I have to give all class file of jotsimple also ?
>>
I just downloaded jot-simple.
I'll give it a try and see
>>
I thought you didn't want to install extra software..?
I just downloaded jot-simple.
I'll give it a try and see
>>
I thought you didn't want to install extra software..?
ASKER
I'll try both and see.
Today is my first day of java programming and trying to do too many things at once and probably jumping a lot.
Today is my first day of java programming and trying to do too many things at once and probably jumping a lot.
>>Today is my first day of java programming
In that case keep it simple: use what i posted and you can go for a more reusable and extensible solution later
In that case keep it simple: use what i posted and you can go for a more reusable and extensible solution later
ASKER
I found one more tool
jargs.gnu which is also good one.
jargs.gnu which is also good one.
ASKER
Thanks, I am planning to use jargs.gnu as it is fairly simple.
Thanks once again for the direction.
Thanks once again for the direction.
:)