Cmd is not showing Java Version - java

I am running for Java -version & javac -version in my cmd, but it isn't showing any output.
It just goes to the next line, and doesn't show anything.
Can anyone here can help me. Any solution ,guys?
I have also added an environment variable for it.
I have attached a screenshot of it.

I got an answer to this.
Here this came after running the command where java.exe,
here I see that I have two java.exe. On inside Common files and another inside Java. So , Because of this only I wasn't getting the answer.
PS C:\Users\absasahu> where.exe java.exe
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Program Files (x86)\Java\jre1.8.0_333\bin\java.exe
After deleting the first java.exe file, I got my work done.
https://i.stack.imgur.com/KSKal.png

Hi download java this one:
https://download.oracle.com/java/19/latest/jdk-19_windows-x64_bin.exe ( sha256)
Then go Settings , environment variable , JAVA_HOME C:\Program Files\Java\jdk-19\NewJava . I created newJava as folder while installing Java . and also set path C:\Program Files\Java\jdk-19\NewJava\bin
Then type in command prompt java -version

Related

"java -version"in cmd gives no result

I tried to install java 14 manually on Windows 10. I set the System Variables as in this picture.
But when I use the command "java -version" literally nothing happens...
C:\WINDOWS\system32>java -version
C:\WINDOWS\system32>
Something must be wrong, but I can't figure what...
Move C:\Program Files\Java\jdk-14.0.2\bin\java to the beginning in the PATH variable.
Important - Open a new cmd window and use the command java -version. Any already open cmd windows do not reflect the settings that you do in the environment variables form/window.
Solution
Please first run the following command
"c:\Program Files\Java\jdk-14.0.2\bin\java" --version
If that returns a result remove the following entries from your PATH
c:\Program Files\Common Files\Oracle\Java\javapath
c:\Program Files\Java\jdk-14.0.2\bin\java\bin
Then create an environment variable called JAVA and set it to %JAVA_HOME%\bin, then simply add %JAVA% to your PATH variable.
You will need to close your command prompt window and reopen it before the change will take effect

Unable to run Jmeter.bat

I'm trying to use Jmeter but am coming across an issue when I try and run it using the Jmeter.bat file.
It's spits out the following error:
'java -version 2>&1 | findstr /i "version"' is not recognized as an internal or external command, operable program or batch file.
Not able to find Java executable or version. Please check your Java installation.
errorlevel=2
Press any key to continue . . .
I've tried googling this and lots of posts mention that this error is usually down to the environment variables not being set correctly, but I'm fairly sure they are as if I type java or javac into the command prompt I get a response.
I've got them set as follows:
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
I tried taking the string it's complaining about and pasted that into the command prompt by itself and it ran fine:
C:\Windows\System32>java -version 2>&1 | findstr /i "version"
java version "1.8.0_25"
So why is it throwing the error when running the batch file but not if I paste it in manually? The batch file is located in a folder in my C drive and I'm running by right clicking and selecting 'Run as Administrator'. If I just double click the .bat file I get the error:
Windows cannot find 'C:\apache-jmeter-2.13_src\bin\jmeter.bat'. Make sure you typed the name correctly, and then try again
Is the above error related or is that a separate permissions issue?
Thanks for any help
From command Prompt go to bin folder of apache jmeter and type following command:
C:\apache-jmeter-3.0\bin> java -jar ApacheJmeter.jar
I also faced similar problem when I extracted the JMeter in C. In my case, i don't have admin rights. I assume it is related to some permission issue. So better copy to D: and then check.
Copy C:\apache-jmeter-2.13_src folder to other drive (D:) or download JMeter and extract in D drive and run the batch file.

Compiling and running java application using powershell

I am trying to compile and a sample Helloworld.java file.
I have my jdk installed in C:\Program Files\jdk1.7\bin.
And I have my Helloworld.java in C:\Helloworld.java
I am actually a novice in both powershell and java.
I got some examples from web regarding this but many of them advice to run it like this:
java.exe -classpath $Env:CLASSPATH C:\Helloworld.java
But when I give this in powershell I get an error called 'CLASSPATH' is not defined even after adding it in env variables.
And when I try to compile the code with the following syntax:
$javac C:\Helloworld.java I get an error "javac is not recognised as a token".
So, I am literally lost in this topic . Any step by step procedure to run java programs using powershell for dummies like me will be greatly appreciated.
Setup environment variables in your system.
set JAVA_HOME to C:\Program Files\jdk1.7
add to PATH variable the string %JAVA_HOME%\bin
open new cmd session.
navigate your java source folder.
use javac to compile your java files.
UPDATE:
also if you are experiencing difficulities upon launching an executable via PowerShell check this Microsoft TechNet article
The variables you speak of do not exist in PowerShell as you name them.
The correct variable names are
$Env:JAVA_HOME: C:\jdk1.6.0;
$Env:PATH: C:\jdk1.6.0\bin;.;
$Env:CLASSPATH: C:\jdk1.6.0\lib;.;
As they all must be defined in the ENV: PSDrive
To answer it in a much simpler way , its the path problem .
You probably not have set env variables that's it.
This is how you should set it:
JAVA_HOME: C:\jdk1.6.0;
PATH: C:\jdk1.6.0\bin;.;
CLASSPATH: C:\jdk1.6.0\lib;.;
And later if you open a cmd prompt and type java -version , if you are able to see the java installed version then you are good to go.

Error while installing Elasticsearch on Windows

I have setup the Java path and I tried to run ElasticSearch on Windows 7. But I'm getting this error:
"no java.exe found on C:\Program Files\Java\jdk1.7.0_17\bin\".
I can run java & javac, they work fine.
How do I solve this issue?
So, I've kept hitting this problem and the solution is twofold. Like Udit said your Java_Home path should not include the bin folder (the reason being that the elastic search bat file seems to add on the bin folder manually, so if you add it the path would be bin\bin)
The second thing to check for is spaces in your path. If Java is installed to C:\Program Files then use C:\Progra~1 and if it's in C:\Program Files (x86) then use C:\Progra~2.
This should mean your Java_Home is set to something like C:\Progra~1\Java\jre7
To Verify this works open a command prompt and type %Java_Home%\bin\java and press return, you should then see all the command line parameters for Java listed. If you get this far you should be able to just run elasticsearch.bat
JAVA_HOME is the environment variable that points to Java installation directory.
Example: If u have installed Java in 32 bit windows 7 operating system, it would have installed in
C:/Program Files/Java/jdkx.x.x
This path should be put as JAVA_HOME. Probably you have set the path till bin directory i.e. C:/Program Files/Java/jdkx.x.x/bin
that is why it cannot find the java.exe.

'"java.exe"' is not recognized as an internal or external command,

I have downloaded both Java jdk1.7.0_06 and Java jre7. and i added the following system variable JAVA_HOME C:\Program Files\Java\jdk1.7.0_06\bin to my windows 7. But when I type the following in the CMD command line on my windows 7 C:\activiti-5.10\activiti-5.10\setup>ant demo.start to run a demo application I got the following error in the command line '
"java.exe"' is not recognized as an internal or external command, operable program or batch file
So does anyone know how i can solve this problem ?
BR
If you look at the "ant.bat" file, you will see that it looks for the "java" command in the following way:
If the %JAVACMD% environment variable is set, then it uses that.
Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
Otherwise, it tries to use java.exe; i.e. it will look on your %PATH%.
In your case, you have %JAVA_HOME% set ... but set to the Java installation's "bin" directory, not to the root of the installation. So the Ant.bat script looks in the wrong place for java.exe.
Just set %JAVA_HOME% correctly, and it should work.
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
As you can see from the above, you do not need to have the Java "bin" directory on your %PATH% for Ant to work, but it is a good idea to set it anyway. That way you can run the Java commands simply from the command line.
The setting of %CLASSPATH% is not relevant to this problem. Indeed, unless the build.xml file is broken, Ant will ignore your %CLASSPATH% environment variable.
You need to put the file java.exe in your PATH variable but the JRE in JAVA_HOME
JAVA_HOME is the path of JDK root folder.eg: C:\Program Files\Java\jdk1.7.0_06 but path define C:\Program Files\Java\jdk1.7.0_06\bin
JAVA_HOME C:\Program Files\Java\jdk1.7.0_06
JRE_HOME C:\Program Files\Java\jre1.7.0_06
path = C:\Program Files\Java\jdk1.7.0_06\bin;C:\Program Files\Java\jre1.7.0_06\bin
Typically JAVA_HOME should be the parent directory of the "bin" folder.(jre or jdk)
In this case ant expects the java to be from the JDK.
try following in a cmd window
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_06
set path="%JAVA_HOME%/bin;%path%;
ant
(side note: adding java.exe to path is not a requirement for ant; it is a convenience thing for the user)
Just delete the following set of files from your %windir/System32 folder. Actually deleting java.exe is enough but for consistency sake just delete all the java related binaries.
java.exe
javaw.exe
javaws.exe
Actually oracle windows installer places a copy of these files into %windir/System32 folder (which I don't understand why) but looks like they are not needed (as they are available anyway under JDK folder where you install them).
I have tried all the various solutions posted in the SO and other forums as well but none of them worked for me. I have also set all the relevant environment variables (JAVA_PATH, CLASS_PATH etc) correctly as well. Finally this is the only solution that has worked for me.
Go to the \squirrel-sql-3.9.0>squirrel-sql.bat .open that squirrel-sql.bat in Notepad and comment out the existing logic which is
=======================================
if exist "%IZPACK_JAVA%\bin\javaw.exe" (
set LOCAL_JAVA=%IZPACK_JAVA%\bin\javaw.exe
) else (
set LOCAL_JAVA=javaw.exe
)
echo Using java: %LOCAL_JAVA%
=================================
and add the below logic
#echo off
set LOCAL_JAVA=C:\Program Files (x86)\Java\jre7\bin\javaw.exe
echo Using java: %LOCAL_JAVA%
================================
make sure you add the correct path of javax.exe while adding above logic set LOCAL_JAVA=
and start the .bat file from CMD ..that's it. It should work. It worked for me.
I started getting this error in Android Studio after I updated it to version "Electric Eel".
It happened because Android Studio has changed where they put their JRE:
it used to be C:\Program Files\Android\Android Studio\jre
but now it is C:\Program Files\Android\Android Studio\jbr
To fix:
updated my JAVA_HOME environment variable to point to the new java location (C:\Program Files\Android\Android Studio\jre)
and then restarted Android Studio, and now it is fixed.
I agree with the above explanation but if the problem still persists try setting:
CLASSPATH = C:\Program Files\Java\jdk1.7.0_06\bin

Categories