This question already has answers here:
Execute another jar in a Java program
(7 answers)
Closed 5 years ago.
I am having the java main application which needs to execute another jar file and return it without waiting for the jar execution complete. Is it possible to achieve it using Java. Can anyone give some inputs in it.
Do following:
Runtime.getRuntime().exec("java -jar <PATH_OF _JAR>");
in your Main class.
And as #Yoav has suggested. You need to take care of errors by adopting proper error handling strategy.
Do Read - https://www.tutorialspoint.com/java/lang/runtime_exec.htm
Related
This question already has answers here:
Error: Selection does not contain a main type
(24 answers)
Closed 4 years ago.
I'm a bit new in Java aka. IDE
As you can see, there is a Main Method, but it still does not accept it. I tried to rightclick the .java class and run, but still did not work
Thanks!
Right Click project-->Properties-->Java Build Path in source tab add your project src
This question already has answers here:
How to run a JAR file
(12 answers)
Closed 6 years ago.
I downloaded this file from a website ! The problem is that I have no knowledge of java :p ! ( I cannot execute that file )
Here's the file:
Atome.jar
When I double click, nothing happens !!
Please guys help me !
This jar was not created to be executed with a simple double-click but probably to be used in a program. In fact, in the Manifest file which is in the jar, there are no Main class defined and none of the class files in the jar is the Main class (I tried with the 3 principal classes)
So, this jar is probably just a library that should be used by a developer
This question already has answers here:
"The public type <<classname>> must be defined in its own file" error in Eclipse [duplicate]
(8 answers)
Closed 6 years ago.
Start. Applet not initialized. My source code doesn't have any "bugs", but I am still unable to successfully run and compile the source code on Eclipse. How do I get the source code to successfully run and compile on Eclipse?
You have a made a common error, often situated with novice Java programmers. You have a class named ConvertCelsiusToFahrenheit, but the name of the file isn't the same. Remember, that one Java class is allowed per file (unless if nested or not public), and the file must have the same name as the class. See the question for why a file must me named as its class
This question already has answers here:
Jar file name form java code
(2 answers)
Closed 9 years ago.
I need to get the application's directory with name. For example, if my java application is working at C:\Program Files\example1.exe I need to get it as "C:\Program Files\example1.exe". Or is it working at C:\Windows\example2.exe
I need to get it as "C:\Windows\example2.exe" . How can I do it?
You can use System.getProperty("user.dir") to find where is your working directory.
This question already has answers here:
Closed 10 years ago.
At the moment I'm using bat file to launch my jar and set the java.system.class.loader. Is it possible to do this programmatically to get rid of the bat file?
You can't, because the system class loader is used before the first line of your program is executed.
You may use a different class loader for some classes, but you can't change the system class loader from your running program.