• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can't setup Java on Mac

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble getting Java to run on my MAC .
I'm using the HeadFirst Java book (2nd Ed.)

I  downloaded the jdk-14.0.2_doc-all.zip and jdk-14.0.2_osx-x64_bin.dmg
but i'm having difficulty adding an "entry to your PATH environment variable"

I've tried

"Open up Terminal.
Run the following command: sudo nano /etc/paths.
Enter your password, when prompted.
Go to the bottom of the file, and enter the path you wish to add. [i  added "entry to your PATH environment variable" into this [part]
Hit control-x to quit.
Enter “Y” to save the modified buffer.
That's it!"

It didn't work.

Then i searched for complier and nothing came up.

if i  can't even set up how can i  start the book lool  
Any help is greatly appreciated!
Screen-Shot-2020-09-09-at-06.08.12.png
[Thumbnail for Screen-Shot-2020-09-09-at-06.08.12.png]
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
$ javac -version
javac 14.0.2

That is the correct response to the command and means that your install is working.

$ javac Party.java
Party.java not found

Means that either the file 'Party.java' does not exist or is not in your current working directory. You may have to provide a full or relative path to the file.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Head First is an old book (15 years old now I believe) and so the installation instructions are out of date.
As Carey says, if you're getting a response back from a 'javac -version' call then it has installed.
 
Saloon Keeper
Posts: 27763
196
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

Dave Tolls wrote:Head First is an old book (15 years old now I believe) and so the installation instructions are out of date.
As Carey says, if you're getting a response back from a 'javac -version' call then it has installed.



Is MacOS that old? Things changed a lot over the last 2 decades in the Macintosh world.
 
ada eze
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for replying. Please explain how i can "provide a full or relative path to the file". I'm a complete newbie with no experience. I  was a fashion buyer and psychologist for many years. please provide a step by step guide.

Carey Brown wrote:$ javac -version
javac 14.0.2

That is the correct response to the command and means that your install is working.

$ javac Party.java
Party.java not found

Means that either the file 'Party.java' does not exist or is not in your current working directory. You may have to provide a full or relative path to the file.

 
ada eze
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

Dave Tolls wrote:Head First is an old book (15 years old now I believe) and so the installation instructions are out of date.
As Carey says, if you're getting a response back from a 'javac -version' call then it has installed.



Is MacOS that old? Things changed a lot over the last 2 decades in the Macintosh world.



Thanks for replying. I literally thought no one would respond haha!
Since the headfirst book is really old, what book would you recommend to a novice like myself?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not a Mac person, so i can't be much help...

where did you save your file named "Party.java"?  Since folders can be in folders which can be in folders, the full path means every single one, all the way up to the top level.

a "relative path" means relative to where you are currently.  I believe the mac OS is linux based.  so if you are on a command line (or whatever it's called in Mac-land), you can type "pwd" for "print working directory".  it will tell you what folder you are currently in.  if you have a directory like :

and your PWD says you are in SubDir1, then the relative path would be "go up one level, then go down to SubDir2, Down to SubSubDir1, and then find Party.Java". in linux speak, that would be "..\SubDir2\SubSubDir1\Party.java"

The Full path would be "\TopDir\SubDir2\SubSubDir1\Party.java".  The full path will always work, no matter what directory you are in, but the relative path changes depending on where you are.

Hope that helps a little...

 
ada eze
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I  saved it on desktop. When i  type pwd it comes up as (see attached file)

fred rosenberger wrote:I am not a Mac person, so i can't be much help...

where did you save your file named "Party.java"?  Since folders can be in folders which can be in folders, the full path means every single one, all the way up to the top level.

a "relative path" means relative to where you are currently.  I believe the mac OS is linux based.  so if you are on a command line (or whatever it's called in Mac-land), you can type "pwd" for "print working directory".  it will tell you what folder you are currently in.  if you have a directory like :

and your PWD says you are in SubDir1, then the relative path would be "go up one level, then go down to SubDir2, Down to SubSubDir1, and then find Party.Java". in linux speak, that would be "..\SubDir2\SubSubDir1\Party.java"

The Full path would be "\TopDir\SubDir2\SubSubDir1\Party.java".  The full path will always work, no matter what directory you are in, but the relative path changes depending on where you are.

Hope that helps a little...



I
Screen-Shot-2020-09-09-at-14.38.55.png
[Thumbnail for Screen-Shot-2020-09-09-at-14.38.55.png]
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
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
MacOS is based on BSD (Berkley) Unix, although Linux is enough like Unix that it often transfers. Outside of certain configuration files and the package installation (MacOS uses something called Brew). Then again,  the same can be said of Linux distros.

The best up-to-date  instructions for installing Java on MacOS should be on the Oracle website, assuming you're using Oracle Java and not the open-source Java that has now become a standard install on many Linux distros.

As for path, I held off because the mechanism indicated was unlike anything I'm familiar with. On most Unix-like systems, I'd set the PATH environment variable in my login profile script, which would either be $HOME/.profile or $HOME/.bash_profile (since bash is my preferred shell). There is no Global Path in Unix like there is in Windows. And using backslashes in file paths is a sure indication of Windows infection. All Unix-like systems use "real" (forward) slashes. Backslash is something that crept into usage via Teletype™ keyboards courtest of DEC and thence to CP/M to MS-DOS.

Note that if you change a profile script you have to log out and back in again for it to take effect, since the profile scripts are run as part of the login process.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:using backslashes in file paths is a sure indication of Windows infection.


Such is my curse.  I have to go back and forth between Windows and Unix all day long, and always get them backwards (or forwards...depending..)
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
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
In Java, forward slashes work even under Windows. Actually in some parts of Windows you can use forward slashes. The main problem with full support is that where Unix used a dash ("-'") as a switch indicator to the command shell, DEC used the forward-slash, and Windows is still mostly inclined that way to this very day. Except in cases where the programs in question were lifted from GNU, Unix or Linux.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ada eze wrote: thanks for replying. Please explain how i can "provide a full or relative path to the file". I'm a complete newbie with no experience.
...
please provide a step by step guide.

I would suggest exploring the OS command shell before diving into programming. Programmers are typically considered as power users who can command systems to do their tasks.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:. . . "Party.java"? . . .

Is that the Party class from the early pages of Head First Java by Sierra and Bates? The book doesn't explain very well that Party is incomplete and its code cannot be run as it stands.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
Is MacOS that old? Things changed a lot over the last 2 decades in the Macintosh world.


The public beta of OS X was in Sep of 2000.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic