I have a problem with an executable jar file. When I launch my jar file with Windows command line, all is good :
java -jar updater.jar
When I double click on my jar file, nothing happens.
This problem appeared when I added graphic support to my application (org.eclipse.jface and org.eclipse.swt).
My MANIFEST.MF :
Main-Class: Updater
Class-Path: libs/
Thank you in advance
It will not open with double click, because that would be like you typing javaw updater.jar in cmd.
The thing you need to do is write a wrapper for the thing. Maybe VisualBasic as it is easy to understand. You can write an updater in it and use AmazonAWS to host your update files. That's what I do, and I reccomend you to do that too.
Solution (thx a_horse_with_no_name for clues) :
With an application which use platform dependent component (like org.eclipse.swt.win32.win32.x86_64_3.102.1.v20130827-2048.jar), set ftype jarfile to JRE that correspond to your architecture (32 or 64 bit) in commands line prompt (run as administrator) :
ftype jarfile="C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -jar "%1" %*
or
ftype jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
All works fine now, thank you !
Related
I am having various .jar files in my system.
I have the JDK and JRE installed.
Most of jar files run on double clicking, but there are 2 - 3 jar files which do nothing on clicking. Help me.
By the way I am using windows 10 64 bit
Problem:
I could not start JAR files just by clicking on them in Windows 10.
I was messing around with the "control panel" ... forget it.
What I've found out:
Start a command line (cmd) as an Administrator
Check your file type association:
ftype jarfile
assoc .jar
I had to change my java path to a different one
ftype jarfile=C:\myjavapath\javaw.exe -jar "%1" %*
Which basically means, that if someone starts a jar file, the command would be:
C:\myjavapath\javaw.exe -jar "example.jar" parameter1 parameter2
For me, I also had to change my .lnk files to only contain the name of the jar file, not the whole command. Type in the whole path of the jar file in the "target" field in the properties of the link file (.lnk).
You can debug it in the Command Prompt.
Open start, type in CMD.exe, hit enter
Then, type in
java -jar "path\to\file.jar" without the quotes
or
java "path\to\file.jar"
You should be able to see an output log of what is happening that is making the jar file not execute properly
Your Manifest file should contain a line:
Main-Class: classname
See "Setting an Application's Entry Point".
I can't open .jar file on Windows 10 (I have tried everything like reinstalling Java and setting the default app to open it to be javaw.exe) and I don't exactly trust jarunner/jarfixer so I want to make a batch program which would detect whenever a .jar is being opened it would get the path of it and would run java -jar [pathtofile].
You'll need to execute this as administrator:
ASSOC .jar=jarfile
FTYPE jarfile=c:\java\java.exe -jar "%1" %*
setx PATHEXT "%PATHEXT%;.jar"
Just put the correct path to the java.exe . Mind that you'll have to keep all your dependencies in the %classpath% vatiable.
More for ASSOC and FTYPE commands.
I am not sure if this is related, but I used this tool http://launch4j.sourceforge.net/ to make .exe from .jar
I need to launch a Jar file with a portable JRE. It works on Windows thanks to launch4j, it works on Ubuntu thanks to me, but not on Mac ..... and I can't test it.
The path tree of application:
abcmap/
launcher.command
bin/
abcmap.jar
jre/
bin/
java
Thinking it's like Unix system, I tried this (without specify bash):
./bin/jre/bin/java -Xms512m -Xmx1024m -jar ./bin/abcmap.jar
But this error appear:
MacBook-Pro:~ frcstnt$ /Applications/abcmap-mac/abcmap.command;
exit;
/Applications/abcmap-mac/abcmap.command: line 1:
bin/jre/bin/java: No such file or directory
logout
All files are rwx for all,
All files are UTF8 without BOM
I tried to change end of line to Unix and to "Old Mac" with Notepad++,
Archives are available on my website:
http://abc-map.fr/download/
https://translate.google.fr/translate?hl=fr&sl=fr&tl=en&u=http%3A%2F%2Fabc-map.fr%2F
Someone can help me please?
Edit: I think my problem is in the launcher, maybe encoding or bad command ?
Edit: Thanks to the Wim's answer it works. This is the script:
#!/bin/bash
SCRIPTDIR=$(dirname $0)
cd $SCRIPTDIR
${SCRIPTDIR}/bin/jre/bin/java -jar ${SCRIPTDIR}/bin/abcmap.jar
The path ./bin/jre/bin/java will be resolved relative to the current directory, not relative to the location of the command file. Try what happens if you run the command from the directory where the command is located.
I think I've found thanks to Wim Deblauwe. I use this:
#!/bin/bash
SCRIPTDIR=$(dirname $0)
cd $SCRIPTDIR
${SCRIPTDIR}/bin/jre/bin/java -jar ${SCRIPTDIR}/bin/abcmap.jar
Find the script dir, go to this dir and start operations.
It seems like you maybe don't even have the Java Runtime Evironment installed. You should try running java -version or at least java -h or java --help.
If you output is something like the following:
java: command not found
You should download and install the latest JRE and try again.
If, however, you see your java version, try first using cd to go to the directory of your jarfile and then use:
java -jar -otheroptionshere jarfile.jar
I hope this helps! Tell me, if you still got issues.
I have a java desktop application that contains the following code:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
System.out.println("check1");
int intResult = compiler.run(System.in, System.out, foutErrorFile, strvalidatePath);
System.out.println("check2");
When I run the corresponding .jar file of this application by executing "java -jar name.jar", both check1 and check2 gets printed and app works fine.
But when i try to run the jar by double clicking the .jar file, I found that ToolProvider.getSystemJavaCompiler() is returning null. "check2" does not get printed. I dont get proper result from compiler.run().
I did modify the registry entry "\HKEY_CLASSES_ROOT\jarfile\shell\open\command" from
"C:\Program Files\Java\jre1.6.0\bin\javaw.exe" -jar "%1" %* to
"C:\Program Files\Java\jre1.6.0\bin\java.exe" -jar "%1" %*.
This way I'm able to see the console when the app is running.
So why is my program (which runs fine while run using java -jar command) malfunctioning when I run the .jar file by double-clicking?
I got my problem solved. While double-clicking, the command that gets executed is the one specified in registry entry. In my case the registry entry "\HKEY_CLASSES_ROOT\jarfile\shell\open\command" is:
"C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
This means its uses the javaw.exe app in the JRE directory to execute the program. My JRE directory lacked one .jar file named Tools.jar in its lib folder. This was essential to acquire the compiler during the program execution.
I copied the missing jar file from the JDK directory lib folder to the same in JRE directory. This solved my problem. Thank you to all for helping.
I think the best way is create a .bat file who calls java -jar name.jar
This pretty much has me defeated.
On XP and earlier versions of Windows you could customise Open With filetypes to include java - jar "myjar.jar", but on Vista this functionality seems to have been removed. I can of course create a .bat file to launch my application, but is it possible to make Vista execute a .jar as required?
You can do it from the command line with 2 utilities.
The first one, ASSOC, is used to create a file association. To verify if there is one defined for JAR type :
>assoc .jar
.jar=jarfile
If not found then create it with :
>assoc .jar=jarfile
The next step is to define the association. This is done with FTYPE.
To verify if one is already defined , type
>ftype jarfile
jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*
Again if not found or the wrong JRE is used, use FTYPE to fix the problem
>ftype jarfile="C:\Program Files\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*
Use the software JarFix >= 1.1.0 .
There is Vista support included and it "recovers" the .jar association!
download for example here:
http://www.softpedia.com/get/Others/Miscellaneous/Jarfix.shtml