How to make a java executable jar file invoke command line? -
i have following simple program:
package meep; import java.util.scanner; public class enterstring { public static void main(string[] args) { scanner in = new scanner(system.in); string string1; system.out.println("enter string"); string1 = in.nextline(); in.close(); system.out.println("here entered: " + string1); } }
what want make runnable jar file run program on command line (i know how make runnable jar file).
in other words, want make runnable jar file such opening file have same effect if type java enterstring
in command line.
also, i'm using windows, make platform-independent (i.e., invoke command line on mac or linux system)?
for windows;
cd /applicationpath java -jar app.jar
save .bat file - double click open application
for linux;
cd /applicationpath java -jar app.jar
save .sh file
for mac;
#!/bin/bash cd "/applicationpath" java -jar app.jar
save .sh file
chmod 777 <.sh file path>
run application.
set .sh file run on terminal, double click start application.
i haven't tested linux , mac, if mistake, please update answer. thanks.
Comments
Post a Comment