where is java installed?

where on the mac is Java installed? I have java 1.6, but I want 1.5 (since will be running Tomcat 5.5..) also, it says here,
http://www.javatester.org/version.html
that Java that comes with the mac comes from Apple and not from Sun, and that it tends to be buggy, so I might as well install it on my own.. my main question is: where do I install it? I don't know b/c can't find the install that is there now (found version by typing java -version in unix shell, but when search for "java" I can't find where sdk/jre is installed.. )

......l

acutally, ran a search, found Java install in system/.../frameworks/javaVM.framework.. so do I install 1.5 in system/.../frameworks/?? (need to make very sure two installs, 1.6 and 1.5, are kept separately, too bad javaVM.framework dir doesn't have version in its name (if I un-install 1.6, would that adversely affect anything in the machine I don't know about that needs java 1.6 to function?)

thank you..

iMac

Posted on Oct 3, 2010 2:11 PM

Reply
19 replies

Oct 3, 2010 2:31 PM in response to kali90

kali90 wrote:
I have java 1.6, but I want 1.5 (since will be running Tomcat 5.5..)


Have you tried running Tomcat first? I think that would be the first step. If you encounter problems, then you can come back here and ask. If you don't have problems, forge ahead.

http://www.javatester.org/version.html
that Java that comes with the mac comes from Apple and not from Sun, and that it tends to be buggy,


I wouldn't put too much faith in that site. The site's author doesn't seen to understand that if Sun isn't so kind as to write a JVM for your OS, you have no option but to do it yourself.

There are instructions posted on how to install Java 1.5 on Snow Leopard, but try it with Java 1.6 first. If that fails, then we'll talk.

Oct 3, 2010 2:35 PM in response to kali90

Google finds the [Apple Java FAQ|http://developer.apple.com/java/faq> (which looks a tad stale), and [thread=2140099|http://discussions.info.apple.com/thread.jspa?threadID=2140099] and [threadID=2138244|http://discussions.apple.com/thread.jspa?threadID=2138244], among other responses.

Snow Leopard includes only Java 6. I'd stay there if at all feasible, as rolling your own environment means more work to set up, and more work as you get to maintain that. (Where Apple will generally deal with Java 6 problems and updates for you.)

As for your question:

$ whereis javac
/usr/bin/javac
$

Oct 3, 2010 3:32 PM in response to MrHoffman

thank u very much for yr responses.. have run searches and found where Java is installed.. have decided to install tomcat 6 to not twist myself into pretzel trying to fit a square into a circle.. so: only instructions have found to install specif. tomcat 6 are here,
http://www.malisphoto.com/tips/tomcatonosx.html

the unix part seems complicated ("The OS X developer tools must be installed to compile the MOD_JK connector, Native Library, or the JSVC daemon..." oh man...)

but well, first thing tried to do was set JAVA_HOME env var.. following instructions on this page did

set JAVA_HOME /Library/Java/Home

but not sure if it took, not sure what command is in unix to list all env vars.. I thought it was 'env' but running command 'env' the list of env vars does not include JAVA_HOME, even after I set it.. at first did

set JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

didn't see env JAVA_HOME when ran command 'env' so did the other way (first mentioned above, the instructions on pg I mentioned); either way, don't see JAVA_HOME in list of env vars.. so not sure what the deal is.. I need really good documentation on unix/mac os; this one
http://www.peachpit.com/articles/article.aspx?p=31442&seqNum=3
has wrong command for setting env var (setenv -- that command is not found in my unix..)

so: first step is I need to set up JAVA_HOME env variable, but am not succeeding in this simple task....;-)

thank you..

Oct 3, 2010 4:37 PM in response to kali90

kali90 wrote:
thank u very much for yr responses.. have run searches and found where Java is installed.. have decided to install tomcat 6 to not twist myself into pretzel trying to fit a square into a circle.. so: only instructions have found to install specif. tomcat 6 are here,
http://www.malisphoto.com/tips/tomcatonosx.html


I am getting to the point where I distrust anything I see on the internet about Apple products that doesn't end in "apple.com". Technically, those instructions are correct, but way too confusing. They are trying to cover all situations for 100% of all users. It would be far better to just focus on the most common 95% and let the outliers fend for themselves. If they are outliers, they can probably figure it out anyway.

the unix part seems complicated ("The OS X developer tools must be installed to compile the MOD_JK connector, Native Library, or the JSVC daemon..." oh man...)

but well, first thing tried to do was set JAVA_HOME env var.. following instructions on this page did

set JAVA_HOME /Library/Java/Home


Use:
export JAVA_HOME=/Home/Java/Home
and put that line at the end of the file ".bash_profile" in your home directory.

but not sure if it took, not sure what command is in unix to list all env vars.. I thought it was 'env' but running command 'env' the list of env vars does not include JAVA_HOME, even after I set it.. at first did

set JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home


That is just a more confusing way of referring to the same path as above.

Oct 3, 2010 6:36 PM in response to etresoft

thank you for your response..

ok, did

export JAVA_HOME=/Home/Java/Home

that worked.. ("export" to set env var? hmmm...)

however, can't find a file called .bash_profile in my home dir... .bash_history is only file I found in there with similar name.. (why would I need to do this in .bash_profile? do I need to set all env vars like this??) I know basic unix commands (the most commonly used we all know), but don't know too much beyond that.. have much to learn, fast.. have no idea what this .bash_profile file is for..

(can Finder be configured so files names that start with a dot appear in Finder window when go to my home dir in Finder (or any other dir? ) )

thank you very much..

Oct 3, 2010 7:19 PM in response to etresoft

I am getting to the point where I distrust anything I see on the internet about Apple products that doesn't end in "apple.com".


well, here's Tomcat stuff on apple.com
http://developer.apple.com/internet/java/tomcat1.html

this pg talks about Tomcat 4, it hasn't been updated since 2001!! it seems to me this page should be kept up to date according to what version of Java mac OS comes with (if mac OS now comes with Java 1.6, this page should be updated with info/instructions for Tomcat 6..)

so it looks like I have to create .bash_profile file.. what do I put in it? (apart from what you suggest?)

thank you..

Oct 4, 2010 5:42 AM in response to kali90

kali90 wrote:
however, can't find a file called .bash_profile in my home dir...


Create it.

(why would I need to do this in .bash_profile?


Because calling export only sets environment variables for the current shell instance. If you put those commands in .bash_profile, they will be executed for each instance of your shell.

do I need to set all env vars like this??)


Yes. More or less. There are some other ways to set environment variables (man path_helper).

(can Finder be configured so files names that start with a dot appear in Finder window when go to my home dir in Finder (or any other dir? ) )


I don't know. There may be some hidden defaults setting for this. I tend to keep the UNIX world separate from the Finder world.

Oct 4, 2010 8:22 AM in response to kali90

kali90 wrote:
thank you very much for your response.. found a neat download called EasyFind, finds hiddden files..


You should try the command "ls -alh"

at any rate, mainly need to know now what all to put in .bash_profile (apart from line you suggested to JAVA_HOME env var..) is there necessary content that has to go in there?


That is a hard question to answer. I think you only need JAVA_HOME for while you are building Tomcat. I don't know. Most things that go into .bash_profile as just Terminal and/or shell enhancements are are not strictly needed. Anything can be done on the command line. Things in .bash_profile just make the command line easier to use.

Oct 4, 2010 9:18 PM in response to etresoft

ok, created .bash_profile, set JAVA_HOME env var
(export JAVA_HOME=/Home/Java/Home)

downloaded Tomcat 6, unzipped, started up tomcat (tomcat/bin ./startup.sh), but url http://localhost:8080/index.jsp does not load.. not sure what more to do.. in windows had to also set CATALINA_HOME env var, but it seems here you don't need to (acc. to these instructions
http://www.malisphoto.com/tips/tomcatonosx.html#Anchor-Tomcat)
and indeed I can see it's set when I see tomcat starting up and I see stuff like

Using CATALINA_HOME: /Users/<user>/apache-tomcat-6.0.29

this is all I see when I start up tomcat:

Using CATALINA_BASE: /Users/<user>/apache-tomcat-6.0.29
Using CATALINA_HOME: /Users/<user>/apache-tomcat-6.0.29
Using CATALINA_TMPDIR: /Users/<user>/apache-tomcat-6.0.29/temp
Using JRE_HOME: /Home/Java/Home
Using CLASSPATH: /Users/<user>/apache-tomcat-6.0.29/bin/bootstrap.jar

doesn't show any errors or problems.. but still http://localhost:8080/index.jsp doesn't load.. what am I missing??

thank you very much..

Oct 5, 2010 7:29 AM in response to kali90

I think the JAVA_HOME environment variable is only required if you want to build Tomcat. I just now downloaded the "binary" distribution, unzipped it, and started it right up with no problem. No JAVA_HOME anywhere. Once again, random pages on the internet are proved to be not only completely wrong, but hopelessly complicated as well.

Since JAVA_HOME is not needed, I say remove it. Reboot your computer to get back to a fresh start. Make sure your local version of Apache is running correctly. Download the correct "binary" distribution of Tomcat from http://tomcat.apache.org/download-60.cgi - I used the Core .tar.gz version. Unzip it somewhere. I used my "Downloads" folder. Run bin/startup.sh. If that doesn't work, run Console.app, show all messages, and look for some sort of error indicator.

Oct 5, 2010 10:01 AM in response to etresoft

well, this is the thing with the JAVA_HOME var: you do need it if you will be developing in Tomcat (not building the server, but developing webapps in Tomcat), b/c when JSP's are requested in browser they get compiled automatically by the Tomcat servlet container, and for that they need to find where the JAVA compiler is; I have been using Tomcat for about six years now, and that I do know..

so: it worked for you b/c you didn't compile anything, and of course it should work for me also w/o it since at first just loading whatever came w/tomcat..

what I did: downloaded package you said, tar.gz, put where I want tomcat to be, unzipped.. started tomcat in way I described yesterday..

am thinking that maybe Apache is not turned on since I have rebooted my machine since I last restarted it (when tested the php stuff..)

thank you very much..

Oct 5, 2010 11:54 AM in response to kali90

kali90 wrote:
I have been using Tomcat for about six years now, and that I do know..


That makes sense. I haven't touched Java in six years and know nothing about Tomcat.

so: it worked for you b/c you didn't compile anything, and of course it should work for me also w/o it since at first just loading whatever came w/tomcat..


I think just getting it up and running is the first step regardless. You will need JAVA_HOME to compile your Java, but you won't need it to run the byte code "binaries" in Tomcat.

am thinking that maybe Apache is not turned on since I have rebooted my machine since I last restarted it (when tested the php stuff..)


Look at Web Sharing in System Preferences > Sharing. If that is behaving strangely, you can inspect the log files via Console.app.

Oct 5, 2010 6:38 PM in response to etresoft

oh brother... I simply don't believe this.. a no. of mysteries:

1) my PHP is running fine, which means Apache server is turned on, which means it remains turned on even if I reboot machine - which I find very interesting...

2) in Windows I never had to deal with Apache server for Tomcat; if Tomcat for Windows needed Apache it must have come bundled with Tomcat; I only ever just started up Tomcat, and nothing else..

3) commented out *export JAVA_HOME=/Home/Java/Home* line in .bash_profile, and guess what? it works!!! I don't get this... even ran of my own webapps (that +must have+ been compiled by the servlet engine..) and it's running fine.. I simply don't get this.. so how does Tomcat find the compiler without the JAVA_HOME variable? this is a complete mystery to me... bizarre...

at any rate, thank you very very much for your help and your patience.. I really appreciate it..

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

where is java installed?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.