Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Introduction. Head first java. Windows 10.  RSS feed

 
Maxim Hapeyenko
Greenhorn
Posts: 4
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, i have decided to start programming in java and i have bought a book about it today (Head First Java). I can't exactly transtale into english what is written in the paragraph for you because im reading the book in my own language, but hope you will understand me How to make terminal know where to find javac? I need to be able to use % javac in cmd as it is said in the book.

Hope you have understood my strange english Waiting for some help from good friendly people here

I use win10.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15890
82
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

You'll need to modify the PATH environment variable to include the bin directory of the JDK. Here is a good page which explains how to do that: How to Edit Your System PATH for Easy Command Line Access in Windows

It explains how to set the path for the Android SDK, but it's basically the same for the JDK. Suppose that you installed your JDK in C:\Program Files\Java\jdk1.8.0_92, then you have to add: C:\Program Files\Java\jdk1.8.0_92\bin to the PATH.

Note that you'll have to close and re-open the command prompt window to make it pick up the change.
 
Maxim Hapeyenko
Greenhorn
Posts: 4
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, i ve done what is said there, but.. take a look at the screenshot below:


I have added a variable path, but there is another path, which is always used and which you see on the screenshot in cmd. How to choose the path i have created?

 
fred rosenberger
lowercase baba
Bartender
Posts: 12464
43
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's very hard to read screenshots...but people can try.

if you type this on the command line, what to you get back:

echo %path%


Also, a 'path' variable just contains a bunch of directories. When you type a command, the operating system looks in every directory in the path to see if it can fine the executable name in one of them. As soon as it finds a match, it stops looking. So, as long as your path contains the directory where your javac.exe is in it somewhere, it should work.

when you do the above command, does the path with your javac.exe show up in the list? if so, what happens when you type

javac -version


if the path isn't there, did you open a new cmd window AFTER saving your update to your path?

 
Knute Snortum
Sheriff
Posts: 3603
86
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "path" you're seeing in the command line is just the current directory.

To see if javac is working, type javac -version

Note on your post: screenshots aren't the best may to get the most responses here. Better is to copy and paste text.
 
Maxim Hapeyenko
Greenhorn
Posts: 4
Chrome IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Owh, guys, i have decided to check if there is such file javac.exe, and i havent found it!! I have tried to run another .exe file through cmd and now i know the path variable works. Maybe oracle changed the name of the file.. dont know. So what file to run?
Here is a list of .exe files in the bin folder:
1) jabswitch.exe
2) java.exe
3) javacpl.exe
4) java-rmi.exe
5) javaw.exe
6) javaws.exe
7) jjs.exe
8) jp2launcher.exe
9) keytool.exe
10) kinit.exe
11) ktab.exe
12) orbd.exe
13) pack200.exe
14) policytool.exe
15) rmid.exe
16) rmiregistry.exe
17) servertool.exe
18) ssvagent.exe
19) tnameserv.exe
20) unpack200.exe

The list here is rather long, but i think that the file i need is in the first ten numbers.

P.S. Maybe it will help you, here are .exe files who have java icon:
1) java.exe
2) javacpl.exe
3) javaw.exe
4) javaws.exe
 
Campbell Ritchie
Sheriff
Posts: 54030
130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are all those files in your ..\Program Files\Java\jdk1.8.0_xx\bin directory? And no javac.exe? The following is a list of files in my Java® bin directory:-If you add .exe to their names, since I am running Linux, you should find more or less the same in a Windows® installation folder. Seeing java and javaws but not javac makes me wonder: what did you actually install? Did you install a JRE or a JDK? How large was the download? You should install a JDK. You can tell which you downloaded by its size; the JDK is about 190MB and the JRE is much smaller, about 60MB
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15890
82
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at your screenshot: it looks like you installed the JRE instead of the JDK.

The JRE (Java Runtime Environment) does not include the Java compiler; only the tools needed to run (but not compile) Java programs.

You need to install the JDK (Java Development Kit) instead of the JRE.

If you actually installed also the JDK (which you probably did since you say you have javac.exe somewhere), then use the correct path - add the bin directory of the JDK to the PATH, not the bin directory of the JRE.
 
Maxim Hapeyenko
Greenhorn
Posts: 4
Chrome IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys!!! You all have helped me a lot! I have started to love this forum because there are so many kind people Have a nice day!)
 
Campbell Ritchie
Sheriff
Posts: 54030
130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our pleasure to help
 
Hinok Yohannes
Greenhorn
Posts: 15
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Welcome to the Ranch!

You'll need to modify the PATH environment variable to include the bin directory of the JDK. Here is a good page which explains how to do that: How to Edit Your System PATH for Easy Command Line Access in Windows

It explains how to set the path for the Android SDK, but it's basically the same for the JDK. Suppose that you installed your JDK in C:\Program Files\Java\jdk1.8.0_92, then you have to add: C:\Program Files\Java\jdk1.8.0_92\bin to the PATH.

Note that you'll have to close and re-open the command prompt window to make it pick up the change.

Thank you this helped me as-well!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!