Java Command Line Launchers

I am working on a .jar file library to implement a bunch of helper classes for interacting with a piece of PC external hardware. I will also add some simple applications, both command line and GUI, to handle common tasks using the library.

My question is, is there a recommended way to simplify a JVM command line instance in a certain way?

eg. instead of requiring the user to enter a critical error, for example:

java -cp TurboBlenderLib.jar -jar TurboBlenderApp.jar -DFoo=Bar arg1 arg2

instead i do

TurboBlenderApp arg1 arg2

?

I suppose I could use shell scripts (including win32 batch files ... gacckkk), it's just that I am not good at these +. I was wondering if there was a simpler platform-independent way to launch a Java application from the command line.

+3
8
  • -jar, -cp ( CLASSPATH)
  • . "java -jar TheApp <whateverargumentsyouwant>" ( Class-Path jar, ).
  • / . .
+5

, . , - Launch4j.

+2

, . ( Java.)

, , . Java.

C, , ( Java-) . (C - ).

, . OS X .app, Windows EXE. Linux, , .: -)

+1

- . , jar, Main-class:, jar , .

$ java -jar myapp.jar

jar, . , shell- script, .

Java Tutorials.

+1

java -jar , , Class-Path . . jar file spec.

+1

Jakarta Commons, : .

+1

The batch file will complete the task. Place the exact command you want to execute in the myProg.bat file and run it.

0
source

This is pretty easy:

Write this in TurboBlenderApp.cmd:

java -cp TurboBlenderLib.jar -jar TurboBlenderApp.jar -DFoo=Bar %1 %2

// Keep in mind saua answer about -cp and -jar

Then from the command line you simply write:

TurboBlenderApp arg1 arg2

Just the way you wanted.

If on Unix / Linux replace th4e% 1% 2 with $ 1 $ 2 and make sure your application has execute rights (if you don’t know how to do this, I think you don’t need it either)

0
source

All Articles