• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Adding PATH entry on MacOS

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Im just started learning JAVA and trying to understand the "add entry to PATH environment".

Im using MAC OS btw, and have no idea how to do this, I do understand only on windows.

anyone can help?
 
Rancher
Posts: 1170
18
IntelliJ IDE Hibernate Firefox Browser MySQL Database Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch
It might sligthly be slightly different depending on the version of os you have on your mac, but it's something like:

 
  • Open up Terminal.app (Applications >> Utilities >> Terminal)

  •  
  • Type: emacs .profile

  •  
  • add this to the end of the .profile file:
            JAVA_HOME=/Library/Java/Home
            export JAVA_HOME;

  •  
  • Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)

  •  
  • Open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version


  • If you see something like:
    java version “yourVersion″
    Java(TM) 2 Runtime Environment, Standard Edition (build yourversion-b06-284)
    Java HotSpot(TM) Client VM (build yourVersion, mixed mode, sharing)
    Then you’ve successfully set your JAVA_HOME environment variable to the binary stored in /Library/Java/Home/bin/java
     
    Marshal
    Posts: 69411
    276
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Welcome to the Ranch

    Since you replied to a ten‑year‑old thre‍ad, I have created a new thre‍ad for you.
    Try the following two instructions at a terminal window. If you get a suitable version number, with javac not higher than java, printed, you may not need to update anything.Please see this FAQ about half‑way down, where you find these two links: 1 2 telling you about PATHs on a Mac.
     
    Saloon Keeper
    Posts: 22112
    151
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Unless MacOS is different than Linux, emacs is probably not installed on it by default.

    I love emacs, but there's some truth that it isn't really a text editor, it's an OS pretending to be a text editor, so usually it has to be installed separately.

    The most common editor that's "always" installed on Unix-like OS's is vi, but vi is one of those programs where if you sneeze, you've probably just entered a long series of commands to do something horrible, so check to see if "nano" is installed, first. It's more likely to be available pre-installed than emacs and a lot friendlier than vi.
     
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Type: emacs .profile


    add this to the end of the .profile file:
           JAVA_HOME=/Library/Java/Home
           export JAVA_HOME;

    ? Hello, I am also new to the programming world. I am getting into the " Head First Java 2nd edition", and I'm not getting the above instructions. Should I type it like this " emacs .profile JAVA_HOME=/Library/Java/Home export JAVA_HOME;" or should I type "emacs .profile" hit enter then type the remaining command?
     
    Kyle Sutton
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Kyle Sutton wrote:Type: emacs .profile


    add this to the end of the .profile file:
           JAVA_HOME=/Library/Java/Home
           export JAVA_HOME;

    ? Hello, I am also new to the programming world. I am getting into the " Head First Java 2nd edition", and I'm not getting the above instructions. Should I type it like this " emacs .profile JAVA_HOME=/Library/Java/Home export JAVA_HOME;" or should I type "emacs .profile" hit enter then type the remaining command?





    Again this is what I am getting after I follow the instructions.
    : Last login: Thu Jun 18 21:27:36 on ttys000
    Kyles-MacBook-Pro:~ kyle$ emacs .profile
    Kyles-MacBook-Pro:~ kyle$ $JAVA_HOME/bin/java -version
    -bash: /bin/java: No such file or directory
    Kyles-MacBook-Pro:~ kyle$ $JAVA_HOME/bin/java-version
    -bash: /bin/java-version: No such file or directory
    Kyles-MacBook-Pro:~ kyle$


     
    Tim Holloway
    Saloon Keeper
    Posts: 22112
    151
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Better off typing "emacs ~/.profile" or "emacs $HOME/.profile".

    Otherwise emacs will attempt to edit the .profile file in the current directory and that won't work unless you are currently in your home directory.

    You also have to log off and back on again before it will work, since ".profile" is executed as a script during login.

    Also, emacs isn't installed by default on all Unix-like distros, so the whole thing could potentially fail, but that's not the case here.

    This should work until you get your profile fixed, though:


    Where the "$" in column 1 is the shell command prompt (you don't type that part in.)
     
    Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
    Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF
    htttp://www.e-iceblue.com/free-apis.html
      Bookmark Topic Watch Topic
    • New Topic