Command Line Argument Parsing in Java

Status
Not open for further replies.

CodingWolf

Smack-Fu Master, in training
77
Hi All,

I find myself needing to write a Java console application and am quite rusty. Can anyone recommend a good analogue to Python's optparse library (or comment on the Apache Commons CLI)?

Also, this is probably a stupid question, but if I wish to use the Common CLI library is it sufficient to include the source within my "project" or do I have to go through some extra work as far as configuration is concerned?

Thank you kindly in advance.
 

esquilax

Ars Tribunus Angusticlavius
9,260
Subscriptor
Commons CLI has been enough for my use, although I haven't ever had to do anything extensive.

Basically in Java you generally use 3rd party libraries packaged as JAR files, which are essentially specially-formatted ZIP files with the compiled classes in them. You'd either include the paths in your invocations of javac and java with the -cp command line switch, or if you're using a build tool or IDE, it'll have its own method of managing the classpath.

Having the source around to compile against will work fine if you want to go that route, but it's not the type of thing that's generally done, especially because as you add more libraries to a project, things could get pretty unwieldy.
 
Status
Not open for further replies.