This week's book giveaways are in the Cloud/Virtualization and Go forums.
We're giving away four copies each of Cloud Native Transformation: Practical Patterns for Innovation and The Go Workshop and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Help adding entry to PATH environment variable that points to /bin

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I recently purchased the book Head First Java, because I'm interested in learning Java.
The book asks me to "add an entry to your PATH environment variable that points to the /bin directory inside the main Java directory. For example, if the J2SDK puts a directory on your drive called "j2sdk1.5.0", look inside that directory and you'll find the "bin" directory where the Java binaries (the tools) live. The bin directory is the one you need a PATH to, so that when you type: javac at the command-line, your terminal will know how to find the javac compiler."

I have no idea what this is talking about, but I have Windows 10, I've downloaded the latest version of Java Development kit, and also the API documentation for that kit. Can someone please help me out in doing this?
Thanks in advance!
 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch Daniel.
I hope you find the community here welcoming, sharing and helpful.

I understand that setting this up can be troublesome and please note that I'm not brushing you off, however, will you please start with going over these two postings:
  • https://coderanch.com/t/687593/java/Setting-environment-variables-command-line
  • https://coderanch.com/t/689105/java/Win
  • These may help you point you in the correct direction.

    I do have a couple of follow up questions, if I may:
  • Also, which version of Java are are you using?
       There are many to choose from, the most people are using either Java 8 or Java 9 or possibly Java 10.
  • Are you using (or planning on using) an IDE? If so which one?

  •  
    Daniel Maguire
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Pete! That was a very quick response, thank you.
    Okay I read the posts, my java version is 1.8.0_171
    Now I made it to adding a path variable in my environment variables, I added the following one;
    C:\Program Files (x86)\Java\jre1.8.0_171\bin
    which I found by finding the java install on my computer and copying the directory, it's not working though (when I type in javac in command line it comes up with "javac is not recognizable as an internal or external command, operable program or batch file").
    Do you know what I'm doing wrong and if so can you help me fix it?
    Thanks in advance.
     
    Daniel Maguire
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    By IDE, would Eclipse Java Oxygen be an IDE? Because I have that at the moment though currently I'm just planning on sticking to whatever it teaches in this book to get a basic/intermediate understanding of Java.
     
    Pete Letkeman
    Bartender
    Posts: 1868
    81
    Android IntelliJ IDE MySQL Database Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Okay, so the next step would be to see what is in your path variable. You can do this by opening up the command prompt and typing path. You should end up with something like (I shortened mine for this post)
    The important parts are the ones with Java in them, in my case C:\Program Files\Java\jdk-9\bin\.
    This works for me because that is where javac.exe is located on my system.

    On you system you should have javac.exe located C:\Program Files (x86)\Java\jre1.8.0_171\bin.
    If you don't have javac.exe located there then you need to update your path to point to the correct place where javac.exe is located.
    After you have updated you path you will need to close all command prompts and start a new one to get the changes to take affect.

    If you are still experiencing issues then please post back and share with us the full path of javac.exe on your system and the complete value of you path variable.
    You may need to provide the trailing slash "\" to the variable.
     
    Pete Letkeman
    Bartender
    Posts: 1868
    81
    Android IntelliJ IDE MySQL Database Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Daniel Maguire wrote:By IDE, would Eclipse Java Oxygen be an IDE?


    Yes, sorry IDE stands for Integrated Development Environment and Eclipse is a very popular IDE for Java (and other) developers.
     
    Daniel Maguire
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Okay it's working now, turns out the location was "C:\Program Files\Java\jdk1.8.0_171\bin".

    Thanks for the help!

    If it's not too much trouble could you please explain why I need to do this so I can understand what i'm doing?
    If it's a hassle don't worry about it I'm sure i'll figure it out sooner or later.
     
    Pete Letkeman
    Bartender
    Posts: 1868
    81
    Android IntelliJ IDE MySQL Database Chrome Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It great that you go it working and now you can move forward with programming.

    Daniel Maguire wrote:If it's not too much trouble could you please explain why I need to do this so I can understand what i'm doing?
    If it's a hassle don't worry about it I'm sure i'll figure it out sooner or later.

    Sure, I can try to explain this and that is a great question.

    Javac is the Java compiler. It takes the source could that you create (the .java files) and transforms them into the for that the Java virtual machine can understand.
    You want this setup correctly at the beginning so that you can compile and run your code from the command line if you need to.

    Many IDEs hide these steps from you and in doing so you may not learn all of the steps needed to create your program.
    IDEs are great tools and offer amazing features like code formatting, code completion, integrated debugging, syntax highlighting and more.
    But is useful to know the commands which run in the background so that you can see all the moving part.

    Some IDEs expect you have to Java setup in your path variable so that they can execute the correct commands.
    Other IDEs can automatically find and setup Java for you, however this is still something that you should know how todo.

    I suspect the book you are learning from is trying to teach you all that you would need to know so that you can be an effective Java programmer.
    On some systems you may not have the ability to install an IDE...maybe it's a server and you don't have the correct user permissions.
    However if Java was previously setup on the system by the administrator then you can go back to basics and do things the 'hard' way.
     
    Marshal
    Posts: 66949
    255
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Welcome again

    The operating system goes through the PATH looking for the instruction you have given it; in this case javac and later java, each followed by arguments. The PATH tells it the ocation of that instruction; if you don't use some way to give it that location you will get an error message like the first one shown in this Java™ Tutorials section.
    I hope you didn't pay full price for your book; HFJ is now quite old, but maybe still the best introductory book, and you should be able to get a good copy second hand. Sierra and Bates believe that it is best for people to learn command line instructions including setting a CLASSPATH, which you won't have to so for several weeks “the 'hard' way” before moving on to use an IDE. I think hey are correct in that view.
     
    Daniel Maguire
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the responses everyone!
     
    A timing clock, fuse wire, high explosives and a tiny ad:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!