jar file is not executing on double clicking on windows 7 - java

I have CQ5 executable jar file.It is suppose to be executed on double clicking.But i get error saying "could not find Main class program will exit".The same jar file executed on all my team mates machine but i am unable to execute it.
I am working on windows 7 OS.
I have jre6 installed.
I have done all steps provided in following link .jar file keeps giving me " could not find the main class". Program will exit.
my ftype and assoc is set to propervalue.
there is no problem in manifest file(becoz it executed on others machine).
all my path variables are set properly.
type of file on my system is "JAR" but on everyone else machine its "Executable JAR"
Could not figure out what is problem with my system.
Help plz.

You can alternatively try executing this command from a command console,
first CD to the location where you have the jar file and execute
For Win7 32-bit:
java -Xmx1024M -jar .jar
For Win7 64-bit:
java -XX:MaxPermSize=256m -Xmx1024M -jar .jar
if you have supported version of Java installed correctly, then the command should be able to start the CQ5 server. In that case, for fixing the double click issue, you would need to fix the filetype association of .jar files to open with /bin/javaw.exe
For supported Java versions, refer
CQ5.5 http://dev.day.com/docs/en/cq/5-5/deploying/technical_requirements.html
CQ5.6 http://dev.day.com/docs/en/cq/5-6/deploying/technical_requirements.html

Related

Unable to run .jar files by double-clicking them on Windows 7

Running a .jar file in the command line works fine, but I am unable to execute .jar files on my PC by double-clicking them. What is interesting, the same .jar files successfully execute on my laptop with a double-click.
I included %JAVA_HOME\bin and JDK_HOME\bin in the PATH variable.
I have JAVA_HOME set to C:\Program Files\Java\jre1.8.0_121.
I have JDK_HOME set to C:\Program Files\Java\jdk1.8.0_121.
For some period of time, the Java(TM) Platform SE binary disappeared from the Open with list, and I could not add it until I changed the HKEY_CLASSES_ROOT\jar_auto_file\shell\open\command key in regedit.exe to the appropriate version:
C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe" "%1".
Here is a snapshot of Windows CMD with java -version entered on my PC:
I tried the following methods, with no success:
reinstalling both JRE and JDK,
associating .jar files with C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe,
using assoc .jar=jarfile and ftype jarfile="C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe" -jar "%1" %* in command line,
creating a new system Environment Variable OPENDS_JAVA_ARGS and setting it to -jar.
Additional information:
I am using Windows 7 Professional 64-bit (Service Pack 1) with latest
updates installed both on my PC and laptop.
Running .jar files by double-clicking them used to work on my PC,
but suddently stopped working some time ago. I did not modify
anything related to Java.
I have the newest version of both JRE and JDK (Java 8 version 121).
Of the .jar files I am trying to run, some are GUI Swing applications
and some open the system console (if not already open) using
Runtime.getRuntime().exec(String[]).
I have already tried fixing this problem with solutions on the following links (without success):
How to run .jar file by double click on Windows 7 (64)
How to open/run .jar file (double-click not working)?
I can run .jar files through cmd, but I cannot double click them
Can't Run JAR Files
Notes:
I do not want to open .jar files with WinRAR.
I do not want to open .jar files by running java -jar jarfile.jar in cmd.exe.
I am not looking for a 3rd party application to run .jar files.
For now, I am using C:\Windows\System32\cmd.exe /k "java -jar C:\path\to\jarfile\Program.jar" as a shortcut location to run jar files, but I am not satisfied with this solution as this opens the console to run even Swing applications.
I managed to get Java(TM) Platform SE binary (javaw.exe) in the Open with list by matching paths in HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE registry entries:
HKEY_CURRENT_USER\Software\Classes\jar_auto_file\shell\open\command
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command
Seems like one of the entries pointed to an older version of Java. Now .jar files are finally showing icons, but still do not work on double-click.
UPDATE: SOLUTION
Delete the .jar and jar_auto_file entries from HKEY_CURRENT_USER/Software/Classes and it should work. .jar files should open on double-click again.
Make sure to backup these entries first by right-clicking the entry and choosing Export.
Additional information can be found on superuser.

Running an executable jar file using Eclipse

I have a project file which includes a jar file(monix.jar) and some data(models, plugins, ...). Developers didn't provide source code of it and I need to run it.
I'm working in the eclipse env and I tried this steps:
extracted it in my eclipse workspace(it was extracted under a folder named monix)
in the eclipse:Run > External Tools > External tools Configurations
set location in the Main tab to: D:\eclipse workspace\monix\data\gate\plugins\ANNIE\build.xml (and ofcourse I tried this path too: D:\Program Files Project\Java\bin\java.exe) by Brows File System button.
then set Working Directory to the path of project folder. D:\eclipse workspace\monix by Brows File System button.
Developers have provided a syntax for running it ($ ./monix inputDirectory outputDirectory) so I set Arguments according to this syntax ($ ./monix D:\monixinputs D:\monixoutput)
When I run it, there is an error:
Exception occurred executing command line.
Cannot run program "D:\eclipse workspace\monix\data\gate\plugins\ANNIE\build.xml" (in directory "D:\eclipse workspace\monix"): CreateProcess error=193, %1 is not a valid Win32 application
I'm totally confused and really need your help,Thanks in advance.
File.jar
If you want only run the program you have to use this file. For run it open cmd or bash in Windows or Linux and write:
java -jar /Path_Of_Your_File/File.jar
(Be sure that you have environment variable "JAVA_HOME" correctly configured)
Build.xml
This isn't for run the program. This file is used, for example, for generate File.jar from the Java code.
Run --> Run configuration in Eclipse
Here you have to specify the name of your project and the name of the main class in your project, but if you haven't the code, you don't have to use this.
D:\Program Files Project\Java\bin\java.exe
This is java.exe, the virtual machine of Java, you don't have to execute this for run your project.

Android.bat can't run java

I know this question has been beaten to death but I still cannot get the SDK Manager to run on my Windows 7 Home.
I downloaded the eclipse + adt bundle. The SDK Manager.exe is in the sdk folder where I try to run it from. I even tried copying it to the tools folder and tried running from there but no luck.
The error I get is:
Failed to execute tools\android.bat:
The system cannot find the file specified.
The file clearly exists. I tried running it as "Administrator" as well.
Next I tried running the android.bat file itself which says:
Windows cannot find 'E:\path\to\batfile'.
Make sure you typed the name correctly, and then try again.
I then ran it as "Administrator" which at least detects and tries to execute it. I added in a few pause statements to android.bat itself to prevent it from closing.
Here is what I see:
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal
or external command, operable program or batch file.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java JDK installed on your system.
We recommend that you install the JDK version of JavaSE, available here:
http://www.oracle.com/technetwork/java/javase/downloads
If you already have Java installed, you can define the JAVA_HOME environment
variable in Control Panel / System / Avanced System Settings to point to the
JDK folder.
Not sure why it says that because when I run where java in cmd I get this:
C:\Users\(MyUser)>where java
C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Windows\System32\java.exe
And when I open cmd and manually run
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s'
it works fine.
I then tried setting the java_exe in android.bat to
set java_exe=C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
After commenting out the find_java I ran it again and this is what I get:
'"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar lib\archquery.jar' is not
recognized as an internal or external command,
operable program or batch file.
Invalid path
And once again, when I manually run it, I get:
C:\Users\MyUser>"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar E:\ADT\sdk\t
ools\lib\archquery.jar
x86_64
Am I missing something or should I finally give up trying to get it to work on my windows machine.
Your where java shows too many java.exe, the find_java.bat will try to look for javaw as well in the folder where java is.
set JAVA_HOME and make sure the echo %PATH% points to your main jdk installation.

Unable to execute .jar file

I'm having a problem with running .jar files. Here's what I've observed:
running executable .jar by doubleclicking doesn't do anything, not even start a process
running it from cmd by typing javaw myfile.jar doesn't do anything as well, I've redirected STDERR but it doesn't say anything
because of school requirements I'm developing in BlueJ, when I run my code directly from this IDE, it works and starts processes like java.exe or javaw.exe
when I try to compile my console program from cmd and then run it by java myclass, it works
I'm working on Windows 7 Professional with Java SE 7u51 JDK installed. I've already tried to uninstall anything that had "java" in its name and then install only JDK or only JRE. I've also tried to run jarfix or manually delete all .jar associations in registry. I've added my JRE path to other system variables. Nothing has worked for me.
Please do you have any idea what to try next? Thank you.
Resolved:
Thanks to the answers I've managed to resolve the problem with doubleclicking as well. I've just had to:
set the JAVA_HOME variable
restart the computer
run jarfix
Couple of quick solutions:
Use java -jar <jar-file-name>
Note: This will be useful if your jar is Runnable
Use java -cp <jar-file-name> main-class-name
Note: Specify the entry point with the class-name to start execution.

What causes "Unable to access jarfile" error?

I want to execute my program without using an IDE.
I've created a jar file and an exectuable jar file. When
I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this:
Error: Unable to access jarfile <path>
I use the command: java -jar Calculator.jar
How I created the jar:
Right click on project folder (Calculator)
Select
Click on Java Folder and select "Exectuable Jar File", then select next
Launch Configuration: Main - Calculator
Create Export Destination
Hit "Finish" and profit! Well, not really.
I had encountered this issue when I had run my Jar file as
java -jar TestJar
instead of
java -jar TestJar.jar
Missing the extension .jar also causes this issue.
Fixed
I just placed it in a different folder and it worked.
[Possibly Windows only]
Beware of spaces in the path, even when your jar is in the current working directory. For example, for me this was failing:
java -jar myjar.jar
I was able to fix this by givng the full, quoted path to the jar:
java -jar "%~dp0\myjar.jar"
Credit goes to this answer for setting me on the right path....
I had this issue under CygWin in Windows. I have read elsewhere that Java does not understand the CygWin paths (/cygdrive/c/some/dir instead of C:\some\dir) - so I used a relative path instead: ../../some/dir/sbt-launch.jar.
I had the same issue when trying to launch the jar file. The path contained a space, so I had to place quotes around. Instead of:
java -jar C:\Path to File\myJar.jar
i had to write
java -jar "C:\Path to File\myJar.jar"
Just came across the same problem trying to make a bad USB...
I tried to run this command in admin cmd
java -jar c:\fw\ducky\duckencode.jar -I c:\fw\ducky\HelloWorld.txt -o c:\fw\ducky\inject.bin
But got this error:
Error: unable to access jarfile c:\fw\ducky\duckencode.jar
Solution
1st step
Right click the jarfile in question. Click properties.
Click the unblock tab in bottom right corner.
The file was blocked, because it was downloaded and not created on my PC.
2nd step
In the cmd I changed the directory to where the jar file is located.
cd C:\fw\ducky\
Then I typed dir and saw the file was named duckencode.jar.jar
So in cmd I changed the original command to reference the file with .jar.jar
java -jar c:\fw\ducky\duckencode.jar.jar -I c:\fw\ducky\HelloWorld.txt -o c:\fw\ducky\inject.bin
That command executed without error messages and the inject.bin I was trying to create was now located in the directory.
Hope this helps.
None of the provided answers worked for me on macOS 11 Big Sur. The problem turned out to be that programs require special permission to access the Desktop, Documents, and Downloads folders, and Java breaks both the exception for directly opened files and the permission request popup.
Fixes:
Move the .jar into a folder that isn’t (and isn’t under) Documents, Desktop, or Downloads.
Manually grant the permission. Go to System Preferences → Security and Privacy → Privacy → Files and Folders → java, and check the appropriate folders.
I had a similar problem and I even tried running my CMD with administrator rights, but it did not solve the problem.
The basic thing is to make sure to change the Directory in cmd to the current directory where your jar file is.
Do the following steps:
Copy jar file to Desktop.
Run CMD
Type command cd desktop
Then type java -jar filename.jar
This should work.
Edit: From JDK-11 onwards ( JEP 330: Launch Single-File Source-Code Programs )
Since Java 11, java command line tool has been able to run a single-file source-code directly. e.g.
java filename.java
If you are using OSX, downloaded files are tagged with a security flag that prevents unsigned applications from running.
to check this you can view extended attributes on the file
$ ls -l#
-rw-r--r--# 1 dave staff 17663235 13 Oct 11:08 server-0.28.2-java8.jar
com.apple.metadata:kMDItemWhereFroms 619
com.apple.quarantine 68
You can then clear the attributes with
xattr -c file.jar
It can also happen if you don't properly supply your list of parameters. Here's what I was doing:
java -jar test#gmail.com testing_subject file.txt test_send_emails.jar
Instead of the correct version:
java -jar test_send_emails.jar test#gmail.com testing_subject file.txt
This worked for me.
cd /path/to/the/jar/
java -jar ./Calculator.jar
For me it happens if you use native Polish chars in foldername that is in the PATH.
So maybe using untypical chars was the reason of the problem.
sometime it happens when you try to (run or create) a .jar file under /libs folder by right click it in android studio. you can select the dropdown in top of android stuio and change it to app. This will work
My particular issue was caused because I was working with directories that involved symbolic links (shortcuts). Consequently, trying java -jar ../../myJar.jar didn't work because I wasn't where I thought I was.
Disregarding relative file paths fixed it right up.
In my case the suggested file name to be used was jarFile*.jar in the command line. The file in the folder was jarFile-1.2.3.jar . So I renamed the file to jarFile. Then I used jarFile.jar instead of jarFile*.jar and then the problem got resolved
It can happen on a windows machine when you have spaces in the names of the folder. The solution would be to enter the path between " ".
For example:
java -jar c:\my folder\x.jar -->
java -jar "c:\my folder\x.jar"
To avoid any permission issues, try to run it as administrator. This worked for me on Win10.
I know this thread is years ago and issue was fixed too. But I hope this would helps someone else in future since I've encountered some similar issues while I tried to install Oracle WebLogic 12c and Oracle OFR in which its installer is in .jar format. For mine case, it was either didn't wrap the JDK directory in quotes or simply typo.
Run Command Prompt as administrator and execute the command in this format. Double check the sentence if there is typo.
"C:\Program Files\Java\jdk1.xxxxx\bin\java" -jar C:\Users\xxx\Downloads\xxx.jar
If it shows something like JRE 1.xxx is not a valid JDK Java Home, make sure the System variables for JAVA_HOME in Environment Variables is pointing to the correct JDK directory. JDK 1.8 or above is recommended (2018).
A useful thread here, you may refer it: Why its showing your JDK c:program files\java\jre7 is not a valid JDK while instaling weblogic server?
For me it happen because i run it with default java version (7) and not with compiled java version (8) used to create this jar.
So i used:
%Java8_64%\bin\java -jar myjar.jar
Instead of java 7 version:
java -jar myjar.jar
I had a similar problem where TextMate or something replaced the double quotes with the unicode double quotes.
Changing my SELENIUM_SERVER_JAR from the unicode double quotes to regular double quotes and that solved my problem.
this is because you are looking for the file in the wrong path
1. look for the path of the folder where you placed the file
2. change the directory cd in cmd use the right path
I use NetBeans and had the same issue. After I ran build and clean project my program was executable. The Java documentation says that the build/clean command is for rebuilding the project from scratch basically and removing any past compiles. I hope this helps. Also, I'd read the documentation. Oracle has NetBeans and Java learning trails. Very helpful. Good luck!
Maybe you have specified the wrong version of your jar.
I finally pasted my jar file into the same folder as my JDK so I didn't have to include the paths. I also had to open the command prompt as an admin.
Right click Command Prompt and "Run as administrator"
Navigate to the directory where you saved your jdk to
In the command prompt type: java.exe -jar <jar file name>.jar
Keep the file in same directory where you are extracting it. That worked for me.
This is permission issue, see if the directory is under your User.
That's why is working in another folder!
Rename the jar file and try
Explanation :
yes, I know there are many answers still I want to add one point here which I faced.
I built the jar and I moved it into the server where I deploy (This is the normal process)
here the file name which I moved already existed in the server, here the file will override obviously right. In this case, I faced this issue.
maybe at the time of overriding there can be a permission copy issue.
Hope this will help someone.
Have you tried to run it under administrator privoleges?
meaning, running the command in "Run As" and then select administrator with proper admin credentials
worked for me
I was trying this:
After giving the file read, write, execute priviledges:
chmod 777 java-repl.jar
alias jr="java -jar $HOME/Dev/java-repl/java-repl.jar"
Unable to access bla bla..., this was on Mac OS though
So I tried this:
alias jr="cd $HOME/Dev/java-repl/ && java -jar java-repl.jar"
This did not work "Unable to access jarfile"
"C:\Program Files\java\jdk-13+33-jre\bin\javaw.exe" -jar "C:\Program Files\Maxim Integrated Products\1-Wire Drivers x64\ OneWireViewer.jar"
This does work
"C:\Program Files\java\jdk-13+33-jre\bin\javaw.exe" -jar "C:\Program Files\Maxim Integrated Products\1-Wire Drivers x64\OneWireViewer.jar"
The difference is the single space in front of OneWireViewer.jar not withstanding that it is surrounded with quotes and even has other spaces.

Categories