Wrong Directory for Java JRE - java

When I am trying to run my Modular Audio Recognition Framework (MARF) jar files, it gives me the message:
C:\Program Files (x86)\Java\jre1.8.0_65\lib\i386\jvm.cfg
I see that the directory it is trying to look for the file is incorrect. I have an updated Java jre folder in Program Files. Is there a way to redirect it?
I have tried going to the Environment variables and none actually point to this folder.
CLASSPATH=C:\Program Files\Java\jre1.8.0_60
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
PATH=C:\Program Files\Java\jdk1.8.0_60\bin

What happen if you run following from the command line?
set environment variables
set JAVA_HOME=C:\Program Files\Java\jre1.8.0_60
set PATH=%JAVA_HOME%\bin;%PATH%
check the Java version
java -version
run your application
java -jar SpeakerIdent.jar

Related

javac is not recognized as internal command [duplicate]

This question already has answers here:
javac is not recognized as an internal or external command in windows 7
(3 answers)
Closed 2 years ago.
My current system config is -
Netbeans 12.0
JDK 14.0.2
Windows 10 (64bit)
I have added the environmental variable in PATH manually i.e. C:\Program Files\Java\jdk-14.0.2\bin.
I tried adding using cmd as well. As well as adding the JAVA_HOME as a new variable with value as C:\Program Files\Java\jdk-14.0.2 .
I have used the set command to do this process i.e. set path = "%path%;"C:\Program Files\Java\jdk-14.0.2\bin". Also, I have used the same command without the set keyword.
Since javah command was deprecated for versions of jdk>8, I have tried to use javac -h command as well.
I have also tried to install JDK v. 8.0.2 instead of the current one.
Although there's no javah.exe file in the bin folder, there is however javac.exe file.
I have uninstalled and reinstalled JDK and Netbeans quite a few times.
I am currently working on JNI with Netbeans IDE and C/C++ plugin. (I have successfully installed Cygwin and necessary extension for the file to build. Although I don't know how they affect this problem, still I thought I should add this).
The command I wish to use with 'javah' is the one used for creating a C header from a Java class i.e. 'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'.
But due to this error, I have been stuck for a few days. Please do assist.
Following way you can set Path variable temporary(it can only be used in the same command line):
You should do it this way:(notice =)
set PATH=C:\Program Files\Java\jdk-14.0.2\bin
And if you set JAVA_HOME variable correctly you can do it this way:
set PATH="%JAVA_HOME%\bin"
For setting this permanently read this post :
https://javatutorial.net/set-java-home-windows-10
We should know the reason for this
Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.
However, when we install any third party tool/software then path variable is not updated accordingly.
When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
C:\Program Files\Java\jdk1.8.0_161
Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
C:\Program Files\Java\jre1.8.0_161
We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.
Solution
we need to update JDK or JRE version specific directory location into PATH Environment variable.
In this case use
set path=C:\Program Files\Java\jdk-14.0.2\bin to set JAVA_PATH

JAVA_HOME is not defined correctly on Ubuntu when trying to run Ballerina code?

I have already set JAVA_HOME in the environment variables file as shown below.
I also built ballerina from the source and extracted the zip with the Runtime and the tools as per the Ballerina documentation. However when I try to give this distribution as the Ballerina SDK in IntelliJ IDEA or even in the Terminal and try to run a Ballerina program as shown below:
I get the following error:
Error: JAVA_HOME is not defined correctly.
But when I type:
echo $JAVA_HOME
I get the following output:
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
What am I doing wrong?
Note: Ballerina Version: jballerina-tools-2.0.0-Preview3-SNAPSHOT
The value of your JAVA_HOME environment variable is wrong. It should not to point to an executable but to the location (i.e. a directory) of the Java installation.
In your case the correct value seems to be:
/usr/lib/jvm/java-8-openjdk-amd64
See also e.g. How to set JAVA_HOME for Java?.
Normal Ballerina 1.2 distribution doesn't require JAVA_HOME but this might be different in your case as you're building a preview release.
what #user272735 was partly correct but you can see that I have added the correct Java Home path in the environment file. Actually the problem was that I was working on terminator when changing the java home path in the environment file and running the below command.
source /etc/environment
But I was trying to run the ballerina code in the plain-old Terminal where the path change was not registered yet.
How to resolve:
I had to run the below command in the Terminal as well. Then when I echoed the java path it printed the one in the environment file and the ballerina code also ran without a problem.
source /etc/environment

Java: System cannot find the file C:\ ... java.exe

I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.
I created a helloworld.java application and am able to compile it using:
javac helloworld.java
However, when I try to run:
java helloworld
I get the error:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
How can I solve this?
1.Just go to C:\ProgramData\Oracle\Java\javapath\
2.You will find there shortcuts for java.exe,javaw.exe,javaws.exe which are pointing to a location where they actually are not existing now
3.Go to the jre location where you have installed java like C:\Program Files\Java\jre6\bin
You will find java.exe,javaw.exe,javaws.exe
Create shortcuts for these files and replace with the ones which are present in C:\ProgramData\Oracle\Java\javapath.
It works
Just set %JAVA_HOME%/bin to your path variable.
If you are blocked from modifying system variables from command line, but are able to open up an elevated command prompt, then run a command like this:
setx \M JAVA_HOME "C:\Program Files\Java\jdk1.8.0_25"
But of course, change the directory to point to your installed version of java. Note that the JAVA_HOME path does not point into the bin directory, it stops one level above bin.
I was able to solve this issue. To do so I used the advice from this answer:
Java SE Development Kit 8u25 on a 64-bit Windows 8
Set the following user environment variables (== environment variables of type user variables)
•JAVA_HOME : C:\Program Files\Java\jdk1.8.0_25
•JDK_HOME : %JAVA_HOME%
•JRE_HOME : %JAVA_HOME%\jre
•CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
•PATH : your-unique-entries;%JAVA_HOME%\bin
(make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.)

Correctly install Java for Matlab

I am trying to extract a jar file from Matlab code using javac from Library Compiler (java package).
I have set JAVA_HOME to:
C:\Program Files\Java\jdk1.7.0_71
and added to PATH:
C:\Program Files\Java\jdk1.7.0_71\bin.
When I enter java -version in my console, I get java version jdk1.7.0_71 and running javac -version shows jdk1.7.0_71.
However, it seems that matlab could not find javac, thus, I am not able to compile my .m code into a .jar file. When I tried to compile .m code I got the following:
Error: An error occurred while shelling out to javac (error code = -1).
Unable to build executable.
Executing command: ""C:\Program Files\Java\Java\jdk1.7.0_11\bin\javac" -verbose - classpath "...\MATLAB\R2014a\toolbox\javabuilder\jar\javabuilder.jar" -d "...\features_extraction\for_testing\classes" "...\features_extraction\for_testing\features_extraction\Class1.java" "...\features_extraction\for_testing\features_extraction\Features_extractionMCRFactory.java" "...\for_testing\features_extraction\Class1Remote.java" "...\for_testing\features_extraction\package-info.java""
This is the directory of my java bin folder and javac.exe exists : ...\Java\jdk1.7.0_71\bin\bin\javac? I found this link for compatibility between Java and Matlab2014a(which is my version) here. What should I check in order to correctly link Matlab to Java? A few days ago Matlab was working correctly with Java.
In my PATH I noticed the existence of the following path: C:\ProgramData\Oracle\Java\javapath in which there are three wrong shortcuts to java.exe, javac.exe, and javax.exe. When I type in matlab console getenv JAVA_HOME I am getting C:\Program Files\Java\jdk1.7.0_11 while when I wrote version -java I got: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode. When I write javac in matlab console I am getting: Undefined function or variable 'javac'.
When I try to built C++ library I got a similar issue: Error: An error occurred while shelling out to mbuild (error code = -1).
Unable to build executable.
EDIT: Does the absence of the proper MCR counts in my case?
You said
getenv JAVA_HOME I am getting C:\Program Files\Java\jdk1.7.0_11 while when I wrote version -java I got: Java 1.7.0_11-b21
try to use setenv in MATLAB, doc here http://www.mathworks.com/help/matlab/ref/setenv.html
setenv('JAVA_HOME','C:\Program Files\Java\jdk1.7.0_71');
setenv('PATH','C:\Program Files\Java\jdk1.7.0_71\bin');
Following from the answers in this link
http://www.mathworks.com/matlabcentral/answers/131639-matlab-deploytool-not-working-fails-while-building
seems like you have to install JDK 1.7.0_11-b21, which is the one your MATLAB version is compatible with for compiling into jar. Also, after installing that specific version, you should modify the JAVA_HOME and PATH environment variables. Try that to see if it helps.
I was having a very similar problem with my installation.
I set the environment variable (press > type env > Enter) JAVA_HOME (under "User variables") to my JDK home directory (not the bin folder) without any trailing \ or ;.
The problem occurs because MATLAB cannot execute javac properly, however, in order to work out exactly what MATLAB is trying to execute (which is not working) we need to use the command window and not the Library Compiler.
It appears you have already done this but for completeness I will add the process here for others.
To find what MATLAB executes, click "Open log file" and copy the entire first line.
Paste the first line in the MATLAB command window and add -v to the end.
Press enter to run the command and note the "Executing command:" that is printed to the screen.
Once you have the "executing command" that MATLAB returns for you, check the first path in that command and make sure it matches your javac file.
In your original post you have done this and posted
C:\Program Files\Java\Java\jdk1.7.0_11\bin\javac
a path which contains \Java\Java, if this isn't a typo then it may be a problem as it is not the default Java installation path. You also say after that your installation is at
...\Java\jdk1.7.0_71\bin\bin\javac
which contains \bin\bin and is also not the default java bin install directory, perhaps another typo?
If the path to javac matches exactly you could try copying and pasting the "executing command" into your OS's command window (+R > cmd > Enter) and looking for errors. By doing this we can remove ourselves from the MATLAB installation and if errors still exist it likely has nothing to do with MATLAB.
To see if the same problem could be caused by other environment variables I removed every other path to a java installation (keeping JAVA_HOME) in my environment variables. MATLAB uses the absolute path to the java installation and so it was still able to compile with javac using only the JAVA_HOME environment variable.

Eclipse is not opening

I'm new to java and eclipse. I even saw this type of query on this website. But I have applied all those methods and it was also helpful. But when I try to open eclipse, it is not opening:
This is my path for java
C:\Program Files (x86)\Java\jre6
this is where my eclipse is
C:\Users\New folder\eclipse
But when I run the eclipse I'm getting an error
"A java rumtime environment(JRE) or java development kit(JDK) must be
available in order to run eclipse. No java virtual machine was found
after searching the following location: C:\Users\New
folder\eclipse\jre\bin\javaw.exe javaw.exe in your current path"
Please tell me the possible solution.
Thanks in advance!
If you have installed jdk then Eclipse won't have any issue to start. I think you just have installed JRE to run java programs. You need to install JDK.
To check whether you have installed JDK. Check Path C:\Program Files (x86)\Java. Your Java directory should contain directory jdk1.6.., If you don't have this directory there, search it at other places. If you did not find directory then you didn't install JDK.
Download JDK from here.
You should set JAVA_HOME and JRE_HOME variable. http://www.javawebonline.com/java-se-programming/beginners/java_home-jre_home-environment-variables/
And another suggestion is you should move your java home to another location and test your path to java such as
C:\Java\jre6
instead of
C:\Program Files (x86)\Java\jre6.
Go to C:\Users\New folder\eclipse
Open eclipse.ini file with text editor and add the javaw location there
( right after -vm part ) like so:
-vm
C:/Program Files/Java/jdk1.6.0_33/bin/javaw.exe <--- change to your path
-vmargs
Open the command prompt by pressing Windows+r, type cmd and press Enter.
Type javac and check the output.
If it gives all the options and usage, then you have configured the PATH vairables correctly, or else you have not set them up correctly.
Try it by checking the value at the command prompt.
NOTE
You need to open a new command prompt each time you change the environment variables.
If you have two Program Files folder in your C: drive
such as
C:\Program Files
C:\Program Files (x86)
then try to put your java inside
C:\Program Files
instead of C:\Program Files (x86)
It seems you are running 64 bit eclipse in 64 bit operating system. If you are running 64 bit eclipse then you need 64 bit JDK. Please install 64 bit JDK and run eclipse.

Categories

Resources