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

Tiger in now available on Tiger !

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java 2 SE 5.0 for Mac OS X 10.4 Released
http://www.apple.com/support/downloads/java2se50release1.html
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, but I can't get it configured.

I'm brand new to Macs -- just got a PowerBook last night.

I gather that something like the Windows PATH variable needs to be set, but I don't know how to do this. I think the Terminal command is setenv, but I don't know what variables need to be set or what exactly they should be set to. (And I'm afraid of guessing because I wouldn't know how to get back if I guess wrong!)

Here's where the 5.0 bin directory seems to be...

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home



(NOTE: As advised on the Apple site, I used the new Java Preferences utility to select 5.0. However, this appears to be for runtime environment only -- not compilation.)
[ April 30, 2005: Message edited by: marc weber ]
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I reading the Apple boards, I now gather that the Terminal command might differ depending on whether you're using "bash" or "tcsh." I have no idea what either of these are, although I appear to be using "bash." This is why I'm afraid of messing things up.

(Also, the Java Tutorial at Sun appears outdated with respect to "First Cup of Java" on Macs.)

 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to set JAVA_HOME you need to add it to a file called .bash_profile

open a Terminal and type vi .bash_profile

in the current editor type a (for append) then type this:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home

to save and exit the VI editor - first press ESC to disable append mode - then press 'SHIFT and :' to be able to type wq (write and quit)

you can now close the Terminal window and the open one again - or you can type . ./.bash_profile in the current prompt to reload your bash_profile.

you should now be able to see witch java version you are using by typing java -version


Rene
[ May 01, 2005: Message edited by: Rene Larsen ]
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene,

Thanks for the detailed info, but I think I messed it up after all. At least I know what I did wrong: I appended the profile with the directory without typing "export JAVA_HOME=" first, so now when I open Terminal, I get...

Welcome to Darwin!
-bash: /System/Library/Frameworks/JavaVM.Framework/Versions/1.5.0/Home: is a directory



How do I get clear this?
[ May 01, 2005: Message edited by: marc weber ]
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you download JEdit 4.2 you should be able to open .bash_profile and correct your error.

But be aware that editing files used by the OS should normaly be done in the right text format (because of UNIX) - using the Terminal.

Rene
[ May 01, 2005: Message edited by: Rene Larsen ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rene Larsen:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
you should now be able to see witch java version you are using by typing java -version



This worked, Tomcat 5.5.9 runs on 10.4 but java -version is still 1.4.2_07. Strange, maybe it will update when I restart but I thought changing JAVA_HOME would suffice.

Can anyone explain the Java Preference utility that comes with J2SE 5.0. It let's you order jdk's by preference but it doesn't override JAVA_HOME so I don't see what it accomplishes.

Gary
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rene Larsen:
If you download JEdit 4.2 you should be able to open .bash_profile and correct your error.


I've downloaded JEdit, but how do I find .bash_profile? The new Mac "Spotlight" can't seem to find it (nor can Finder's find function), and I don't know where else to look.

I've seen a lot of references on the internet to this being in the "home directory," but I don't know what this means (there are no files showing in the Home directory under my user name).
[ May 01, 2005: Message edited by: marc weber ]
 
Sheriff
Posts: 67752
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
Welcome to Unix!

Under Unix systems, files that start with the dot character are considered "hidden" and are not generally shown to the user. On OS X this also applies to the finder.

Your "home directory" is the one with your username in /Users. You probably don't already have a .bash_profile if you haven't explicitly created one.

Open a Terminal window. It's working folder will be your home. Enter:

touch .bash_profile

This will create an empty file (if one already does not exist -- if one does, it merely updates the mod time).

To edit this file using tools you are already familiar with, enter:

open /Applications/TextEdit.app .bash_profile

This will launch a TextEdit window with the file loaded.

When done make sure the file has exec permissions with:

chmod a+x .bash_profile
[ May 01, 2005: Message edited by: Bear Bibeault ]
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Bear!

I suspected that this file might be hidden, but I didn't see a way to view hidden/system files.

I was able to open .bash_profile with TextEdit and correct the error I made earlier. I then used Rene's directions to set JAVA_HOME. However, this still isn't working -- even after restarting.

java -version still indicates 1.4. And when I try to compile Java 5.0 test code, it fails to compile. (A simple attempt at autoboxing gives the expected error with 1.4... "found: int / required: java.lang.Integer").

I've double-checked the path by opening .bash_profile in TextEdit again, and verified this against what I'm seeing in Finder (adding the "bin" directory to the path indicated in above posts).

Are there any other variables I need to specify? For example, do I need a "PATH"?
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by marc weber:

I've downloaded JEdit, but how do I find .bash_profile? The new Mac "Spotlight" can't seem to find it (nor can Finder's find function), and I don't know where else to look.

I've seen a lot of references on the internet to this being in the "home directory," but I don't know what this means (there are no files showing in the Home directory under my user name).

[ May 01, 2005: Message edited by: marc weber ]




Open JEdit and navigate to 'JEdit->Preferences...->File System Browser->General' make sure that 'Show hidden files' is marked. If you also make sure that 'Default path' is 'Home directory' then when you try to open a file (from 'File->Open..') you are starting in your Home directory and you should find the file .bash_profile, that you need to modify.

Hope that this helps ;-)

Rene
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rene Larsen:
... make sure that 'Show hidden files' is marked...


Thanks, Rene!

I now have .bash_profile corrected with JAVA_HOME set. However, as described in my last post, java -version still indicates 1.4, and I'm not able to compile Java 5.0 code.

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Appears to me you should be able to just redirect the symbolic link /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK from the 1.4.2 directory to the 1.5.0 directory. This will update your default commands to 1.5 without needing to set any paths at the user level.

Havent tried it yet but the default commands in /usr/bin/ all point to /System/Library/Frameworks/JavaVM.framework/Commands/ which in turn points to /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/

So, make the CurrentJDK directory link to the new 1.5.0 dir and you are away...

I havent tried this so I am not sure if the symbolic links will pick up their new associations but essentially, if they will, just remove the old link:

rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/

Then set up the new one:

ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/

NOTE: I do not know if the existing links will pick up the new link - I will test this when I have a minute and let you know.
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you have to do some more configuration so that 1.5 will be the OS's default Java.

Open a Terminal and type cd /System/Library/Frameworks/JavaVM.framework/Versions

then type ls -la

here you should see an file(link) named CurrentJDK (or something like this) it links to the current Java Runtime and it is this link you have to modify.

The steps I did to do that was:

leave the Terminal open and open a Finder and navigate to /System/Library/Frameworks/JavaVM.framework/Versions

delete the file(link) CurrentJDK in the Finder window - the one you just saw in the Terminal window

go back to the Terminal window and type ln 1.5.0 CurrentJDK to create a new link to the new Java Runtime

when you now type ls -la you should see CurrentJDK->1.5.0

The JAVA_HOME in .bash_profile can also be changed to /System/Library/Frameworks/JavaVM.framework/Home it is a link to Versions/CurrentJDK/Home

Rene
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rene Larsen:
Then you have to do some more configuration so that 1.5 will be the OS's default Java.

Open a Terminal and type cd /System/Library/Frameworks/JavaVM.framework/Versions

then type ls -la

here you should see an file(link) named CurrentJDK (or something like this) it links to the current Java Runtime and it is this link you have to modify.

The steps I did to do that was:

leave the Terminal open and open a Finder and navigate to /System/Library/Frameworks/JavaVM.framework/Versions

delete the file(link) CurrentJDK in the Finder window - the one you just saw in the Terminal window

go back to the Terminal window and type ln 1.5.0 CurrentJDK to create a new link to the new Java Runtime

when you now type ls -la you should see CurrentJDK->1.5.0

The JAVA_HOME in .bash_profile can also be changed to /System/Library/Frameworks/JavaVM.framework/Home it is a link to Versions/CurrentJDK/Home

Rene



The above can be carried out from the terminal using the commands in my previous post if you prefer the command line way...
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rick you are right - I was just to slow posting my comment ;-)

Rene
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rene Larsen:
Rick you are right - I was just to slow posting my comment ;-)

Rene



Posted my previous comment a bit quickly. It may have come across in the wrong way. My intent was to point out that Rene's solution and mine do the same stuff, so you only need to do one or the other, not both.

Re-reading my post I see that it may have come across in a "sigh - thats what I said" but that wasnt what I meant...
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene and Rick,

Thanks for your help! I'm getting closer (I think), but it's still not working.

I was unable to delete the "CurrentJDK" alias using Terminal. It said, "Permission Denied." I was able to delete it using Finder, after entering my system password.

But now I can't create the new alias. When I try Rene's approach of navigating in Terminal to the Versions directory and typing ln 1.5.0 CurrentJDK, it says "1.5.0 is a directory." When I try Rick's approach (adding "-s" after "ls"), Terminal says "Permission Denied."

I tried restoring the CurrentJDK alias from the Trash, but couldn't do this either.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rene, Bear, and Rick: Thanks for your help! I've never used the "beerchug" graemlin before, but now's definitely the time:



The missing piece was to type "sudo su root" in order for Terminal to recognize that you're an administrator on the machine (since you're messing with System info). It then prompts for the password. After that, all is well.

I've posted the final instructions in a separate topic (with a nod to each of you).
 
This one time, at bandcamp, I had relations with a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic