java - .jar from netbeans will not open in console -
built simple java program in netbeans, build/compiled , generated .jar me in project directory.
the following src code:
import java.util.scanner; public class welcome { public static void main(string[] args){ system.out.println("welcome java"); scanner input = new scanner(system.in); } }
i want able open in console use scanner function, can't seem open jar.
i have tried opening command line following:
java -jar "c:\users\nick\documents\netbeansprojects\javaapplication1\dist\javaapplication1.jar"
but no dice. double clicking .jar doesn't open either.
any ideas here?
regards
you need build runnable jar if want start -jar
see https://docs.oracle.com/javase/tutorial/deployment/jar/run.html
you can run jar packaged applications java launcher (java command). basic command is:
java -jar jar-file
the -jar flag tells launcher application packaged in jar file format. can specify 1 jar file, must contain of application-specific code.
before execute command, make sure runtime environment has information class within jar file application's entry point.
to indicate class application's entry point, must add main-class header jar file's manifest. header takes form:
main-class: classname
the header's value, classname, name of class application's entry point.
the alternative run using specifying classpath , main class
java -cp "c:\users\nick\documents\netbeansprojects\javaapplication1\dist\javaapplication1.jar" welcome
Comments
Post a Comment