Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

java-version problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help, when entering the command "java-version", the phrase constantly pops up --
is not an internal or external command, an executable program or a batch file. At the same time, I installed java, but I think I have a problem somewhere in variable environments, apparently I mixed up something there, did everything according to the instructions, but it's still difficult to understand where to insert what
 
Marshal
Posts: 5323
324
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, welcome to the Ranch!

We are an English speaking forum so please ask your questions in English.
 
Marshal
Posts: 75648
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the English translation.
Did you write

java-version

or

java -version

?
The first form is incorrect; only the second form with a space before the hyphen will be recognised. There is no such program as java‑version, but there is java with the −version option.
If java on its own produces that error message, then you need to update the PATH environment variable.
 
Nika Kort
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, java itself does not give it away. I need to set environment variables to work with it (I have already downloaded and unpacked java itself). I tried to lead with a space, but I also get an error. The whole problem is that it is difficult for me to understand what and where to enter in order to set these environment variables. The instructions didn't help me...
 
Saloon Keeper
Posts: 13852
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What operating system are you using?
 
Campbell Ritchie
Marshal
Posts: 75648
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I presume you are using Windows® bcause I have only seen that error message on Windows. If you don't get that error message from java alone, then you have probably set up your PATH successfully. (You will probably get a different error message if you don't name a file after java.) Please copy what you see if you writeat the command line.
 
Nika Kort
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Windows
 
Nika Kort
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote this on the command line. That's what it gave me C:\Users\USER >echo %PATH%
";C: C:\Program Files\Java\jre1.8.0_321\bin\bin; \Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;";C:\Users\USER\AppData\Local\Microsoft\WindowsApps";
 
Campbell Ritchie
Marshal
Posts: 75648
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use the “post reply” button rather than “quote”.

I am afraid that PATH looks incorrect. Assuming you want Java8 (I am using Java18), you are right to move the Java┬« part of the PATH to the beginning. Did you add “C:” at the beginning yourself. I think that isn't a valid part of the PATH because it isn't followed by a ;
The following part, “C:\Program Files\Java\jre1.8.0_321\bin\bin;” does have a ; But it has jre where a developer would need jdk, and it has bin twice. I think it should only have bin once.
Try changing the PATH to:-

C:\Program Files\Java\jdk1.8.0_321\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;";C:\Users\USER\AppData\Local\Microsoft\WindowsApps

Try the following two insrtuctions at the command line and show us the results please:-You might need to add \bin after javapath; I don't know definitely.
 
Nika Kort
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much!! now everything has worked out) With the java -version command, it gives me
C:\Users\USER >java -version
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
 
Saloon Keeper
Posts: 25463
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:You might need to add \bin after javapath; I don't know definitely.



Definitely: the root of a JDK or JRE ("JAVA_HOME") is always the path of the JDR/JRE directory.

The PATH should always be of the form JAVA_HOME\bin, pointing to the directory that contains the JDK/JRE executables.  For JRE's you may find a subdirectory, "JAVA_HOME\jre\bin". It does NOT go in the PATH.

This is true of both Windows and the non-Windows OS's, although the actual semantics of a Windows PATH differ from how systems like Linux/Unix do PATH.

Finally I've used the form "JAVA_HOME" to generically indicate the desired JDK_JRE base directory, but you can substitute in either the explicit absolute filesystem path, or if you've pre-defined it, an actual environment variable expression such as %JAVA_HOME%\bin (Windows), or $JAVA_HOME/bin (Linux, MacOS, etc.
 
Campbell Ritchie
Marshal
Posts: 75648
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nika Kort wrote:Thank you very much!!

That's a pleasure

. . .
java version "1.8.0_321" . . .

Well done. What did you get from javac −version?
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic