I am in the process of writing a command line tool which should work on all popular platforms (Windows, Mac & Linux). I was thinking of writing it in golang
because it can generate statically compiled binaries and works on all the above said platforms. Before I take the decision, I need to evaluate Java
and see if it can do this.
I'm wondering is it possible to create first class command line programs in Java? AFAIK, a Java program needs to be started like
java -cp classpath MyApp
Now I need to wrap this in a shell script to improve the experience. Something like,
#!/bin/sh
java -cp classpath MyApp $@
Now user can do:
myapp --arg1 value --arg2 value
The problem is this approach is not cross-platform. On Windows, I need to write a batch file to do this.
I'm not sure if this is the right way to do in Java. Is there a better way to handle this problem?