This question already has answers here:
How to run .jar file by double click on Windows 7 64-bit?
(18 answers)
Closed 9 years ago.
Sorry if this a little dumb, but I have a .jar file that runs great when i type java -jar quiz.jar. But it doesn't work when i just double click on the file. I have it set to open with java.exe, and all my other .jars work fine. it's just the ones i've created. Any Ideas? Thanks.
What you can do is adding an option in your context menu (using registry).
For example, you can copy this code into a .reg file and run it.
You should have a "Run Jar" option in your context menu. I did it on my Windows installation and it works great.
[HKEY_CLASSES_ROOT\*\shell\Run Jar]
[HKEY_CLASSES_ROOT\*\shell\Run Jar\command]
#="java.exe -jar %1"
If want to remove this option, create and execute a new .reg file which contains :
[-HKEY_CLASSES_ROOT\*\shell\Run Jar]
Simply by doing:
right-click on the JAR,
"Open With...",
and then select the javaw.exe from your JRE's bin folder,
tick the "always use the selected program to open this kind of file".
Note that it has to be javaw.exe, not java.exe. Do browse to the correct location yourself to make sure.
This alternative should work as well.
Related
This question already has answers here:
'Java' is not recognized as an internal or external command
(19 answers)
How to run a JAR file
(12 answers)
Closed 1 year ago.
I've searched for a while for a fix, I think I've tried all of the common fixes, I even tried Jarfix. I have JRE installed, and I deleted and reinstalled it again just to make sure, I'm running Windows 10 64 bit. If I double click the .jar just nothing happens, and I've made sure that .jar is set to open with the right file. I don't know what to try so if you have any suggestions, I'll try them, because I'm completely lost.
Whenever I try to run any command starting with "java" is gives me this: 'java' is not recognized as an internal or external command, operable program or batch file.
First of all, Add your JRE to the PATH of Windows.
When you add it there, running java commands in the command line, will be recognized since JRE will also be indexed.
This is how you add it:
set PATH=%PATH%;C:\your\path\to\jre\bin\here
An example:
set PATH=%PATH%;C:\Program Files\Java\jre1.8.0_271\bin
Then go to the folder where your jar file is located. And open a command line there.
Or go there through the cd command (which means change directory to jump to exactly this directory). Example:
cd C:\Program Files\Java\jre1.8.0_271\bin
And then run your jar this way:
java -jar yourJarName.jar
.jar files have the java directory directly inside of them so you shouldn't have to reinstall JRE.
Maybe your .jar file you are trying to run isn't put together properly.
OR there is nothing to run on your file or there is an error in the code.
Those are all ways it could be broken.
When download a file like "example.jar" the file isn't .jar is just a white file.
I tried finding an other .jar file from my java folder and Run As.. it but it just runned cmd for 1 second and then closed it.
Can anyone tell me what to do?
You have to run it via your cmd with command:
java -jar NameOfFile.jar
And you do not see the file extensions, because you most likely told windows in folder options to hide them.
This question already has answers here:
executing .jar file with an argument by mouse right-click on Windows?
(3 answers)
Closed 8 years ago.
I read this article and wanted to do same thing using Java (.jar) file instead of .exe
And suppose my program just prints the path of the selected file which right clicked to my content menu.
Please see below Image. I want like this the option(Copy File Path) in MS Windows Context Menu using a Java Application:
Sorry for my weird language, i hope somebody fix that.
Best regards
Open with then select java under JDK_HOME.
then you are free to run it after clicking...
You only have to double-click on the .jar file.
This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 8 years ago.
I have one library, one txt file for import some things with it and one output file to show the result. Only have one java file without any interface. With eclipse all is running well - I am writing into the input file and then it shows the result into the output file. Now I want to make this all independent program (without need to run with eclipse).
How to make it?
An easier way is to make a runnable JAR file.
Go into eclipse choose file > export > runnable JAR.
It will then ask you to choose a class for a launch configuration. Choose the class that has the main method for the desired program. After that you will have a file that will run (like a .exe but just a different format).
If can't get it to work with your input and output files, thats because eclipse has this weird thing that sometimes occurs regarding the location of external sources when exporting to JAR. To fix it, just put the files instead of the src (source) folder, one folder up in the directory. For example, if this is your current directory: C:\workspace\myprogram\src put it in C:\workspace\myprogram
Hope this helps.
The only thing that eclipse is is a software that facilitates progtammi g. But what find the programs is the jvm-java virtual machine. To get to the point eclipse does have a option to convert it to a .jar file which the extension a java program uses to be "independent" from eclipse and open up by double clicking. The way you do this is you right click on the class you want to make independent and I think there should an option that says export to .jar and that should do the trick! Hope this was helpful
I've done a search and I can see that a lot of people have had the same problem as me, but none of the solutions have worked for me.
Basically I have a Java Project in Eclipse that is from my old Windows Installation. I've cleaned and rebuilt it because at first it wouldn't compile, but now I have it exported as a Runnable Jar. However, the only way I can get the application to appear is to do java -jar foo.jar in command prompt, or run it in Eclipse. If I double click the JAR in Windows Explorer nothing happens even though I know that Java is associated correctly because other Runnable Jars work.
The project only has the x86 JRE listed in it's Build Path Libraries and all the files listed appear to exist. I'm running Windows 7 HP.
Update: I'm sorry, but I just discovered that no other Runnable Jars are working either. If they are wrapped with launch4j they work though...
Edit: The Runnable Jars that I export from Eclipse do work fine on other systems and load on double click
Some registry values or file associations are probably messed up. Wiping off all of your existing JRE's and JDK's and re-installing them should fix your issue.
Alternatively you may be able to fix it by manually editing the registry value here:
HKLM > SOFTWARE > Classes > jarfile > shell > open > command
My value is
Type: REG_SZ
Data: "C:\Program Files\Java\jre8\bin\javaw.exe" -jar "%1" %*
You'd of course want that path to point to your javaw.exe, and make sure you have the additional arguments.
I was also facing the same problem while i was working with Spring tool suite.
You may use the following steps:-
Right click on project -> export -> Runnable jar file -> (Here,In library handling,there are three options,you have to choose middle one i.e package required library into generated jar.It will package external dependency also).
-In my case, my runnable jar was only executing on my environment i.e on which i have created that JAR. Initially i have selected the first option to create JAR i.e extract required libraries into required JAR.but that was not proper.
It may help you.Let me correct if i am getting wrong.
Since you are able to run the JAR running the command line, I believe your issue is related to which version of Java is set to run the file when it is double-clicked.
To find out which version is successfully running the file from the command line and set it to open JAR files by default:
Open a new command prompt window.
Run echo %path%. Among the path values, you should be able to find one pointing to the bin folder of one of the installed versions of Java. Copy this path somewhere.
Navigate to the JAR file you would like to run. Right click the JAR -> Open with -> Choose default program... -> Browse...
Browse to the path you copied in step 2. (the easiest way is to paste it into the address bar)
Double click javaw.exe.
Click OK.
You should now be able to run the JAR file. Please let me know if your problem persists.
I have made a jar with and keep it on desktop.Then,I double clicked on the jar and it working fine for me.
How I and what I have monintored: In my main class, perform some operation and at the end I add on Thread.sleep(25000); to hold the program for few moments. After every double click on the exported jar I found one new javaw.exe process added in the system process tree. I have noticed it on Task manager. and after 25000ms respective javaw.exe process ended. As my application does not cointain any GUI that's why I have not seen any GUI changes for the respective process. I'm Confident that if my application have some GUI, I will surely get the respective GUI window on every run.
Common mistakes : when we export a project from Eclipse as Runnable JAR file, it is exported with selected Eclipse launch configuration and Eclipse specific launch wrappers. Now if the configuration does not match when you are trying to run it via double-click you will not be able to see the error, If you run it from CMD then surely you will get the error log.
To create standard executable JAR file : To create a standard executable JAR file, you can export as JAR file and specify the main class in last screen of the wizard.
That's working for me fine. I used the same jar from different system and keeping it different location.