I have an AEM jar file AEM_6.5_Quickstart. I am trying to get it running but facing issues.
First thing is my jar is not identified as normal on my system like other jars, as you can see there is no icon associated with my jar file.
Second is when i double click on it to run it i get the below prompt to choose the program to run it with, which ideally should not appear. I was getting errors when i was running maven command to generate project using zulu jdk so i had installed jdk from oracle website, now that is removed from my system and when i double click on jar file i still get the option to run it using oracle jdk
Third problem which i am facing is that when i run the jar using zulu x64 Architecture as in above image it starts the jar but i get the below error when i go to localhost:4502
i google searched for solutions and found that indexing might be the problem so i deleted the file at crx-quickstart/repository/index after stopping the jar. When i restart it it gets stuck and doesnt start for some reason as in below picture, the progress bar doesnt move even though i waited for hours. I also made sure that sling authenticator service was running.
This is the output in case it helps for the java version being used and the path is setup as C:\Program Files\Zulu\zulu-11\bin. I am unable to fix this issue, any help is much appreciated.
First, delete the whole crx-quickstart directory (since this is a local environment being set up for the first time), and this way you will have a clean start. After that, maybe the .jar extension is missing from the filename, please add it. Finally, it is easier to use a .bat or .sh script (you can customize parameters and runmodes for AEM). But for a first run, quick setup with the default sample content, just try java -jar AEM_6.5_Quickstart.jar
It seems like windows messed up with your java versions, you can go and fix your windows JDK references from the registry, you can do that by pressing win + R then type "regedit", once open look for the next value:
"HKEY_CLASSES_ROOT\jarfile\shell\open\command" then open the "default" value and check that your path is correct, mine for example is :
"C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe" -jar "%1" %*
use mine as reference only change the first part between quotes for your path to the JDK.
Usually that should fix it, but some times there are some other registry references that ruin your jar files association, if you can open PowerShell/cmd or bash terminal type java -version and get the proper version of your Java installation, another workaround can be opening terminal, navigate in terminal where your jar lives and then type
java -jar yourJarFile.jar
Related
I am getting "A JNI error has occurred, please check your installation and try again" error Whenever I'm running my java jar using "java -jar filename.jar" command with windows power shell. It works fine whenever I opens it with double click.
How Can I resolve this issue?
Thanks in advance.
You say it works when you double click the JAR file (in File Explorer) but not when you run it from the PowerShell window in this folder:
C:\incubating-netbeans-11.0-bin\netbeans\ani\Tank-IQ-Display-Configurator\Tank-IQ-Display-Configurator\dist
I'm guessing you have more than one JDK installed.
If you enter the following command in the PowerShell window, it will display the paths to all the java.exe files.
where.exe java
Windows associates file extensions with executables. Obviously, on your computer, the .jar extension is associated with java.exe. You can check this via Control Panel. Look for Default Apps. Hence when you double click the JAR in File Explorer the associated executable is launched.
I'm guessing that the default executable is that of JDK 11 and that either in the folder whose path I wrote above there is a java.exe that is compatible with JDK 8 or in your PATH environment variable, the path to the JDK 8 executable comes before the path to JDK 11 executable.
So check those things, i.e.
Default apps in Windows
PATH environment variable
Obviously there are many different ways to rectify the situation. I don't think any one is clearly superior and the most appropriate would depend on your environment and your needs which I am unaware of since you haven't provided those details, hence I won't suggest what actions you should take in order to resolve your issue.
What you do need to do is ensure that a JAR file containing java code that was compiled to JDK 11 is run with a java.exe from at least JDK 11.
Note that higher java versions can run classes compiled to lower versions. In other words, if your JAR was compiled to JDK 8, you could run it with JDK 11, but not the other way around (which is the cause of your error, as others have indicated).
As it says quite clearly in the error message, your JRE is too old. Install a newer JRE (and update your PATH and JAVA_HOME).
Also, please do not post error messages as screenshots when you could also paste them as text.
I'm experimenting with Java for the first time.
I'm using Intellij IDEA and creating a simple app.
In the IDE it's working fine, then I create a JAR artifact and run it like this:
java -jar myappname.jar with no problem.
Now I would like to start the same JAR with double-clicking it from explorer but nothing happens, why?
Please note that if I double click another JAR (sikulixsetup-1.1.3.jar) it starts correctly and show the gui, so the problem is not type association in windows.
My test app does not have a gui but I know if it runs correctly because it's automating windows using Sikulixapi library, so I see if it's doing something or not.
thanks!
Ok, I solved my issue.
Usually the JAR runs without any problem by simply double clicking it in windows,
in my case it was not running becase the .jar files was associated to the 32bit version of javaw.exe while the code in the JAR was expecting the 64bit environment.
Changing the .jar type association in windows from 32bit to 64bit version of javaw.exe solved the issue
Its because jar is not executable binary but plain zip archive. OS cannot execute that. That is why you must use java executable and pass archive as argument to run your application.
If you want your app to be "clickable" you must use some wrapper solution like http://launch4j.sourceforge.net/
Change the default program to use while opening the file from one Java to the other (32 to 64 bit or vice-versa).
I've created a program using Eclipse and exported as an executable jar (I've tried all 3 library handling options). It runs perfectly on the computer it was written and exported on, but when I try and run it on other machines it does nothing at all. It brings up no errors, nothing at all. I've got several people to try it for my with no luck, and I've tried running it on my laptop (ensuring that Java is the latest version, the same as the machine that it was written on). The MANIFEST file points to the Main class correctly.
Does anyone know how I can solve this issue?
It's incredibly frustrating!
If any more info is needed, I can supply it.
That happened to me a lot of times when I started writing java distributed applications.
Check your project build path (since you're using eclipse, right-button click on your project's folder, then Build Path > Configure Build Path). If any of the paths that are specified there are custom *ie C:\User\daMachineMaster\Java\jre\bin or whatever, it won't work on any other machine because the application will always look for that path, which won't exist in no other machine than daMachineMaster's computer. You could use a wrapper to fix this issue, since it encapsulates all needed information in a .exe, for example.
If that still isn't your issue, search your code for any links to your local directories. For example,
String style = main.screens.ScreenFramework.class.getResource("C:\Users\Dwayne\Music\cool\DarkTheme.css");
After you've located these kinds of hard links, the solution is changing them to be relative links. Check How to define a relative path in java
In the above case, it would mean changing to something like:
String style = main.screens.ScreenFramework.class.getResource("DarkTheme.css").toExternalForm();
Also, as mentioned in other answers, check if the other computers hava java installed. I don't think that they need any environment variables defined to run a runnable jar but if you want to run your app in the cmdline with something like java -jar yourapp.jarthen you need to go to the windows explorer (assuming you're using windows), right-click Computer, then click Advanced System Settings > Environment Variables > New... > Variable Name = JAVA_HOME; Variable Value = directory where java is installed > OK > Click on PATH > Edit... > add JAVA_HOME\bin to PATH > OK
When the Java Runtime Environment (JRE) is not installed, the JAR won't be open and won't show you any message. Try installing JRE into the other computer and try again.
You need to install a Java Runtime Environment (JRE) first, then you can directly run the .jar files on your computer. The Java Development Kit (JDK) download package contains it's corresponding JRE, so that's fine to install too.
Sorry for the late reply. Thanks for all your answers, but it turned out there was an error in my code that simply stopped it running without showing any errors.
I got this problem several times. The issue was the jar file runs on the computer where I have packaged. But in another computer it is not running, some time it shows running if I check the javaw.exe process in cmd but nothing is served.
The solution here is to make sure the following are set correctly.
Make sure the version of java in another computer match the jar file. In some case if you defined java16 in the pom file, make sure the computer has java16 or higher installed and the JAVA_HOME environment is set correct to point to this version.
Make sure the dependent variables are set correctly. For example if the package depends on database driver or database connection consider installing and creating database
For me it worked after changing the java version in the pom file to the oddest ie.the second computer use java 16 then packaged jar file to use java 11.
I have a Java console application which I can package into a jar file using IntelliJ, and can run the program with a bat or cmd file which has the following command:
java -jar main.jar
The problem with this is that my development machine (Windows) has the JAVA_HOME and PATH modified so that this works without issue.
Is there a way so that I can package the jar so that it can be opened without needing to modify the PATH?
I've tried looking all over and found questions on SO and other sites relating to building the jar, but it seems like all of these still require modifying the PATH variable.
Java's documentation says:
Making changes to the system PATH variable is not typically necessary for computers running Windows or Mac OS X. The instructions below are intended for advanced users or system administrators only.
If this is the case then how can others run the program if they are not an "advanced user" or "system administrator"?
Edit:
As an aside, I know this is possible because some jar files, like those which use the Swing framework are able to be run by just double-clicking on the jar and then the application opens.
Edit 2:
This article seems to be along the right path.
Edit 3:
This is kinda what I was looking for, however, it didn't work for me. The command I was trying on my existing jar was jar uvfm main.jar manifest.txt which returned updated manifest, but changed nothing.
No you cannot. They are system variables. The best thing to do is to write a shell script that will set these variables.
no. It should be able to understand 'java' command. For this path need to be set. But if you are planning to shift your jar as an application, you need to ship jre as well with your application. But i dont think this is what you want
This is my first question, so apologies for any mistakes. I'll try and give all the info I can. Basically I've written a simple swing application which just loads in image into a JPanel and displays it. I'm using Netbeans 7.1 and I have the latest version of the Java SDK.
Anyway, I've used the "Build" feature in NetBeans 7.1 to deploy my application into a Jar file. When I double click the Jar File on my PC, it runs without a problem. However when I put it on other computers (Tested on 2 others so far, both with the most current JRE) it fails to open, citing the following error:
could not find the main class: swong.Startup. Program will exit
swong is my package name, and Startup is the location of my main method. I have checked the manifest file which is created with Netbeans' build, and it[the manifest] does indeed contain the location of my main method class.
From searching, I've come across similar issues in which the classpath is set wrongly, but I don't understand how this could cause my particular error.
If someone could help me, I would be over the moon. I've been studying java for a year or so, and I've got a good handle down, but I've NEVER been able to make a Jar that runs on a computer which wasn't my own. So, 10 points and thanks in advance.
xo.
EDIT: Thank you for the responses. I'm doing shift work and swamped, but I will test and poke with these responses tomorrow and provide more information. Thanks again. xo
I had d same problem while distributing my app. There is 1 solution that you create a batch file with 'java -jar AppName.jar' and asking user to double click on this batch file to execute your app. What i did was to provide a JRE installation exe(eg: jre_1.7.0) with your app.
Now create a Batch file (install.bat) in which write following commands
jre_1.7.0 -> this will install jre on user's pc
set path="C\Program Files\Java\jre_1.7.0\bin"
java -jar yourAppName.jar
Why i installed JRE because different people have different JRE versions installed. So this makes it difficult to set path to the installed JRE's bin folder & calling the 'java -jar' command. Hence as you know which folders your JRE installation will create hence it is easy to set path and execute your jar file with 'java-jar' command.
Check that your jar file has the following structure (at least)
jarfile.jar
|---------- swong
|---------- Startup.class
|---------- META-INF
|---------- MANIFEST.MF
It seems like the class "Startup" is missing. Maybe your jar only contains the .java files, not the compiled classes.
This error message can be a mistakable java7 error, when you try to start java7 compiled classes with a different Java Runtime Environment then java7. Have you validated, that your .jar is started within a Java7 environment on those other test machines? Sometimes it happens, that you have installed different versions of JREs and you might not be sure which one is actually started.
To check which enviroment is used, you can check in your registry for the following value:
HKEY_CLASSES_ROOT\jarfile\shell\open\command
this should point to your latest JRE. Or if you'd like to stay compatible to java6 as well, define the appropiate compile level in your build environment.