I am using Maven for my project and I need to set environment variables in my system for it to work. I have set environment variable for maven but it also requires setting up Java environment variable. I am accessing linux through Putty through a remote server. I tried setting up JAVA_HOME environment variable but I get this error:
Error: JAVA_HOME is not defined correctly.We cannot execute /home/z222189/jdk1.8.0_31/jre/bin/java
I used export JAVA_HOME=/home/z222189/jdk1.8.0_31/jre for this purpose
Even when i try to execute the java.exe file directlty in linux I get error
-bash: ./java.exe: cannot execute binary file
Any suggestions on how to resolve this issue?
You shouldn't refer to the jre/ subfolder, as Maven will need a Java compiler and potentially other JDK-only tools.
So just use:
JAVA_HOME=/home/z222189/jdk1.8.0_31
EDIT: (making sure that a correct, working JDK is installed at that location, of course...)
Seems you are in Linux, be sure you get Java for Linux!
Set JAVA_HOME using
export JAVA_HOME=/home/z222189/jdk1.8.0_31
Does not work because java is not there, or the version is not the correct, if you already installed correct java linux version and you dont really know where your oracle-java is installed, you can find this running
which java
which will tell you which binary of java is being called, normally is something like
/usr/bin/java
but you can
readlink -f /usr/bin/java
that will give you something like
/usr/lib/jvm/java-7-oracle/jre/bin/java
ergo
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre/
Related
A collaborator has sent me some Matlab code which requires an old MCR version (7.14). I have an installation binary from them, but when I run it I am immediately faced with the message
No Java Runtime Environment(JRE) was found on this system
Has anyone experienced this before? I cannot get around the problem. I have JRE installed. I am running Ubuntu 18.04.
Thank you for any help.
One possible cause may be that JAVA_HOME environment variable is not set, or that it is set incorrectly. The variable should point to the installation directory for the JRE / JDK whose java command you are running.
(Note: a correct JAVA_HOME is never a bin directory, so if you have set your $JAVA_HOME to a bin directory you have done it wrong!)
Thus, the solution may simply be to set the JAVA_HOME environment variable (correctly) in your shell before running the MCR installer.
I have used it [the MCR installer] successfully on numerous other Ubuntu machines.
This is suggestive to me that your problem is an incorrect JAVA_HOME ...
Another possible solution would be to follow the instructions in the MATLAB documentation for doing a "non-interactive" install of MCR.
There is apparently a README file in the zip file. It may contain information about command line options for the installer that relate to the version you are using.
Finally, I suspect that the install command is actually a shell script. There may be clues in the script about command line options and other alternatives for installing.
I am trying to install Oracle SOA Suite 12 on Windows 10. I set the JAVA_HOME correctly (able to echo it), and then trying to run the JAR. It gives me the following message:
This installer must be executed using a Java Development Kit (JDK)
but C:\Program Files\Java\jre1.8.0_161 is not a valid JDK Java Home.
It seems to look for the JRE folder and by default neglecting the JAVA_HOME environment variable. I did a workaround by navigating to the JDK folder, and then running the java.exe inside the JDK folder (java.exe -jar /path/to/soasuite). It works well. I just want to know what might be the reason.
I advise you to set the properties as follow. Adapt correctly to your path in the JAVA_HOME property, and the others will follow.
JAVA_HOME := C:\java\jdk1.8.0_151
JDK_HOME := %JAVA_HOME%
JRE_HOME := %JAVA_HOME%\jre
CLASSPATH := .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
PATH := %JAVA_HOME%\bin;%PATH%
EDIT:
I did a workaround by navigating to the JDK folder, and then running
the java.exe inside the JDK folder (java.exe -jar /path/to/soasuite).
It works well. I just want to know what might be the reason.
This means that you are missing the change in the PATH environment.
I was not able to utilize the path variables described - did not want to restart the machine durng and install of oracle software. I was able to successfully complete the install of weblogic oracle fusion by doing the following.
RUN JAR files using command prompt due to having issues running the java installed setups for oracle12c, weblogic ,etc.
RUN command prompt as adminsitrator:
1. CHANGE DIRECTORY IN COMMAND PROMPT TO:
C:\Program Files\Java\jdk1.8.0_181\bin
RUN the command like this - pointing to the proper JAR file.
java -jar c:\oracleformssoftware\fmw_12.2.1.3.0_infrastructure.jar
This definately worked for me but please note I did finally setup the path variables instructions noted here.
I am writing a blog where I have explain my students how to install Java, but I'm wondering why should expose them to this complicated part of Java installation. When I used Java before, I used right out of the box with my IDE. But all the tutorials I see mention configuration of these environment variables.
Maybe my PATH variables were set from previous installations, however I don't remember doing it.
Can anyone please advise if environment variable setting can be left to the IDEs or has to be done manually?
Java does not need any environment variables to be set.
However, setting some environment variables makes some things easier.
PATH If the jre/bin folder is on the path, you don't have to qualify to run the java command. If the jdk/bin folder is on the path, you don't have to qualify to run the java and javac commands. As well as some other commands provided by Java.
JAVA_HOME Used by many Java programs and installers to find Java.
When using an IDE, it can usually find / prompt for Java installations, so it doesn't need any environment variables. The IDE won't set them either.
As mentioned above, JAVA_HOME Used by many Java programs and installers to locate Java. for instance, Tomcat requires the environment variable JAVA_HOME to be set to the JDK installed directory.
To check if JAVA_HOME is already set, start a terminal and issue:
echo $JAVA_HOME
JAVA_HOME is to be set to the JDK installed directory. You need to find your JDK installed directory.
[TODO] find macOS and Ubuntu JDK installed directory.
Add the the following line at the end of "~/.bashrc" (or "~/.login"). Take note that filename beginning with dot (.) is hidden by default.
[TODO] How to un-hide for macOS/Ubuntu.
export JAVA_HOME=/path/to/JDK-installed-directory
// Verify the new setting
echo $JAVA_HOME
I installed Java and then installed Eclipse, and you know what, it worked fine, however for one of my colleagues it was giving a "warning" regarding not being able to find Java, and error was clearly showing it needs environment variables because it wasn't able to find the path to Java, like Java wasn't installed, while it was installed there.
why do I get this? How can I fix it?
C:\Users\ash>java version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.7.0_01', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
The accepted solution for Reinstalling ALL JDKs was a bit harsh.
I too experienced this problem and here is my 2 cents:
This problem started happening since I installed JDK 8 and still had JDK 6 installed. I need for different projects I'm working on.
I noticed I had both a User and a System %JAVA_HOME%, so I removed my User %JAVA_HOME% variable and left only the system one.
I also noticed that in my Oracle installation there was some Java executables and I believe those where the ones conflicting since both my Oracle and Java installations were in my %PATH% variable.
I removed all Java paths from my %PATH% Variable and only left the %JAVA_HOME%\bin at the start of the variable for avoiding any conflicts with the Oracle installation.
I had a similar issue after installing the java 1.8.
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
Removing
C:\ProgramData\Oracle\Java\javapath;
work like charm
Reinstall JDK and set system variable JAVA_HOME on your JDK. (e.g. C:\tools\jdk7)
And add JAVA_HOME variable to your PATH system variable
Type in command line
echo %JAVA_HOME%
and
java -version
To verify whether your installation was done successfully.
I had a similar issue after installing the java 10.0
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
I had to remove the Common Files javapath from the 'Path' that was conflicting, in order to make it work. Now thankfully the java -version works just fine.
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Make sure your JDK Path variable is directing to the \bin folder and is at the top of the list, because it always uses the first match. By moving it to the top you can make sure that no other path is matched first.
If there's any other entry that has a file called java (such as C:\ProgramData\Oracle\Java\javapath) it will run the command against that file instead of the java file in your JDK. There's no need to reinstall the entire JDK unless your files are corrupt or damaged for some reason.
This problem generally occurs in Windows when your "Java Runtime Environment" registry entry is missing or mismatched with the installed JDK. The mismatch can be due to multiple JDKs.
Steps to resolve:
Open the Run window:
Press windows+R
Open registry window:
Type regedit and enter.
Go to: \HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\
If Java Runtime Environment is not present inside JavaSoft, then create a new Key and give the name Java Runtime Environment.
For Java Runtime Environment create "CurrentVersion" String Key and give appropriate version as value:
Create a new subkey of 1.8.
For 1.8 create a String Key with name JavaHome with the value of JRE home:
Ref: https://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html
I edited my path to put the Oracle JDK at the start of the path and that fixed it.
Problem:
We had the same problem in our Windows 2012 server. We used JAVA_HOME environmental system variable, an we used in the PATH this kind of settings: ...%JAVA_HOME%/bin;...
and no other java related settings was in the PATH.
The problem was we had a space at the end of the value of the JAVA_HOME variable. Like 'C:\Program Files\Java\Jdk 1.8.0_172 ' so the %JAVA_HOME%/bin meant 'C:\Program Files\Java\Jdk 1.8.0_172 \bin'. So because the value was split by space and the system tried to find java.exe at 'C:\Program Files\Java\Jdk 1.8.0_172' where it is obviously not.
Solution was: Delete the space from the end of value of the JAVA_HOME !
Uninstall Java from machine
Check Java folder is deleted from Program Files
Check Registry does not have any instance of Java
Open system Variables and delete the ONLY java path from PATH
Now install the new version again.
Set the Path in System Variables.
This process cleans up all the traces of java and then install fresh java.
Note: This issues occurs when there is multiple installation and uninstall done.
You could be using a 32 bit version of java on a 64 bit environment.
Export the registry hive form HKLM\Software\JavaSoft and import into HKLM\Software\Wow6432Node\JavaSoft. For 1.6 I only needed JavaHome and RuntimeLib values.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment]
"CurrentVersion"="1.6"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment\1.6]
"JavaHome"="C:\\Java\\jre"
"RuntimeLib"="C:\\Java\\jre\\bin\\client\\jvm.dll"
None of the above worked for me, unfortunately.
The error solved when I uninstalled the old JDK versions that were installed on my computer. I did it simply with the "Uninstall or change a program" tool (under the Control Panel).
I removed the "C:\Program Files (x86)\Heroku\bin" from PATH variable and the problem has gone. I think it is probably the Heroku require different version of Java. So check all directories in your PATH variable, remove the possible ones may have confliction.
If you face this error in cmd with another error as "could not find runtime environment" after you have done all settings in Environment Variable. Then you just need to run jre.exe in your jdk folder and reinstall it and then recheck it by java -version command. Hope it will help you.
rename file "C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
CMD --> java -version
done.
In my case the regedit information was correct and the problem was solved by doing the below:
1) setting JAVA_HOME to jdk - set JAVA_HOME=C:\Program Files\Java\\bin
2) setting PATH to jre - set PATH="C:\Program Files\Java\\bin"
after adding the requirements path as illustrated up and deleting C:\ProgramData\Oracle\Java\javapath;. don't forget to reopen your editor.
Go to CMD and type the following:
SET PATH=C:\Program Files\Java\jdk1.8.0_291\bin
(here jdk1.8.0_291 represents your java version, it may differ for you)
i have Windows Vista and i'm trying to install maven and test it.
But i realised that i have a problem with JAVA and i have to solve first.
I do Start->Run->cmd
and i type in the command line,
C:\>mvn clean
i get the following error
ERROR: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
So i say: Let's set the PATH for Java and i did:
Start->Control Panel->System->Advanced System Settings->Environment Variable->System Variables
Edit the PATH variable
C:\Program Files\Java\jdk1.6.0_32;C:\apache-maven-3.0.4\bin;
But then i get the same error when i do:
C:\>mvn clean
Then i typed in the cmd prompt:
C:\>java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
and i realise that the Java version that is running is not located under the
"C:\Program Files\Java" directory
The only JDKs i have are:
jdk1.6.0_29
jdk1.6.0_32
Then i did Run->cmd
C:\>where java
C:\Windows\System32\java.exe
(Recently i downloaded IDE Eclipse and IDE IntelliJ and i don't know if these apps
come with the JDK).
Where can i find my JDK installation in Windows and set the path in environmental variables?
Go to
Start->Control Panel->System->Advanced System Settings->Environment Variable->user variables
Click on new button
give the
variable name : JAVA_HOME
variable value: C:\Program Files\Java\jdk1.6.0_32
in that way you setup your java home and try
Also make sure to take new command prompt after you did any changes in environment variables
Eclipse comes bundled with a JDK, I believe you need a seperate one to run maven.
My environment variables look like this.
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_33
Path = (tacked on the end) ;%JAVA_HOME%\bin;C:\Program Files\Spring Tools Suite\apache-maven-3.0.3\bin
This is all working but as you can see I got maven by installing STS. It's just an eclipse distro which comes bundled with maven (among other things).
You can also set java home from command line prompt. But this will be valid only in your session and it will be gone once you close your command line session.
Hope it helps.
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33
Late to the game, but run this in an elevated command prompt:
setx /M JAVA_HOME "path_to_Java"
This will set the path for your machine and not the user. Remove /M to have it set just for the user account.
The guide at SS64 (and setx /?) say you're supposed to have the /M switch at the end, but my personal experience is that it doesn't always work at the end.