Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Should I edit /etc/profile.env to add path to sun java
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
lnthai2002
Apprentice
Apprentice


Joined: 04 Nov 2005
Posts: 260

PostPosted: Fri May 18, 2007 4:28 am    Post subject: Should I edit /etc/profile.env to add path to sun java Reply with quote

Hi,
I wanna use sun JDK for java applications (netbean, eclipse and others). Should I add path to sun JRE to /etc/profile.env? On Fedora we use /etc/profile.d to store the script to set JAVA_HOME variable, do I need these in gentoo or is there a "gentoo way" to do this?
Back to top
View user's profile Send private message
massimo
Veteran
Veteran


Joined: 22 Jun 2003
Posts: 1226

PostPosted: Fri May 18, 2007 7:10 am    Post subject: Reply with quote

Take a look at [1].

[1] http://www.gentoo.org/doc/en/java.xml

HTH,
_________________
Hello 911? How are you?
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Fri May 18, 2007 7:37 am    Post subject: Reply with quote

yup you could use /etc/profile for PTAH variable or for user only
/home/user/.bash_login => is like .bash_profile if that doesn't exist.
/home/user/.bash_profile => used after /etc/profile
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
lnthai2002
Apprentice
Apprentice


Joined: 04 Nov 2005
Posts: 260

PostPosted: Fri May 18, 2007 9:00 pm    Post subject: Reply with quote

I wanna use sun java-1.6, so i download and unpack the binary files to /opt and export J2RE_HOME. However, when I use java-config -L it does not detect my java_vm although which java show the correct path to java_vm. Is there anyway to config java manually? I intend to set up a java web server.
Back to top
View user's profile Send private message
Insanity5902
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1228
Location: Fort Worth, Texas

PostPosted: Fri May 18, 2007 10:22 pm    Post subject: Reply with quote

lnthai2002 :: Please use portage to maintain your java versions. The Gentoo's devs have gone through a lot of work to make sure everything works, and it does so quite nicely.

Take a look at this http://www.gentoo.org/proj/en/java/java-upgrade.xml and just go through it step by step.

What will happen is you will end up having 2 versions of java a 1.4 to compile apps with, and then another one of your choosing to use as a system vm. I currently have sun 1.6 has my system and haven't had any problems with it. The way Gentoo set it up to source all the information into the environment variables allows you to easily switch your VM on the fly with out having to re-source any profiles.
_________________
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
lnthai2002
Apprentice
Apprentice


Joined: 04 Nov 2005
Posts: 260

PostPosted: Sat May 19, 2007 4:49 am    Post subject: Reply with quote

After reading the upgrade guide for a few times, i still dont see how you can install jdk 1.6 on your system. All i understand is that when i emerge sun-jdk (1.5.0-11) it gonna config this java package to compile any java application which will be EMERGED in the fureture; however, whether I am using this java or other java to compile my app (not through emerging) is up to me but HOW?
Can you give me a hint?
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2508
Location: Silver City, NM

PostPosted: Sat May 19, 2007 5:03 am    Post subject: Reply with quote

Is the problem that the instructions are clear but you just can't believe that they work?

To emerge the 1.6 version of the Sun JDK, add the line:
Code:
dev-java/sun-jdk

to the file /etc/portage/package.keywords. Create the file if it doesn't already exist. Then emerge sun-jdk.

You use the eselect tool to choose which java jdk will be used. Use the command:
Code:
# eselect java-vm list

to see your options.

If you look at the file /usr/bin/javac, you will see it is a symlink to /usr/bin/run-java-tool which is a script you can inspect. This is where the magic happens.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9507
Location: beyond the rim

PostPosted: Sat May 19, 2007 12:08 pm    Post subject: Reply with quote

As it hasn't been said yet: never edit /etc/profile.env directly, it's autogenerated by env-update so any changes will be lost the next time you remove/install a package. If you need to change some env variable permanently edit either /etc/profile, or add a file into /etc/env.d or /etc/profile.d. But as has been set, for java you want to use the config tools instead of editing files manually.
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Mon Jul 09, 2007 9:57 pm    Post subject: Reply with quote

I have followed the instructions and setup my JVMs with java-config

Code:
 # java-config -L
The following VMs are available for generation-2:
1)      Blackdown JDK 1.4.2.03 [blackdown-jdk-1.4.2]
2)      Sun JDK 1.5.0.12 [sun-jdk-1.5]
*)      Sun JDK 1.6.0.01 [sun-jdk-1.6]
4)      Sun JRE 1.6.0.01 [sun-jre-bin-1.6]


as you can see above, 1.6 is my selected (for user and system)

yet my path is still showing 1.4

Code:
 echo $PATH   
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin


how do I force java-config to reuild my path ?
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Mon Jul 09, 2007 11:47 pm    Post subject: Reply with quote

What is java -version is output ?
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Tue Jul 10, 2007 12:14 am    Post subject: Reply with quote

Code:
# java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode)

# which java
/usr/bin/java

# whereis java
java: /usr/bin/java /usr/X11R6/bin/java /opt/sun-jdk-1.5.0.12/bin/java /opt/sun-jdk-1.6.0.01/bin/java /opt/sun-jre-bin-1.6.0.01/bin/java /opt/blackdown-jdk-1.4.2.03/bin/java
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2508
Location: Silver City, NM

PostPosted: Tue Jul 10, 2007 12:18 am    Post subject: Reply with quote

Follow the suggestions at the bottom of my post above to see why this works.
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Tue Jul 10, 2007 12:28 am    Post subject: Reply with quote

your java works well just check the symlink on /usr/bin/java
ls -ln /usr/bin/java
and use eselct for switching
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Tue Jul 10, 2007 12:52 am    Post subject: Reply with quote

mudrii wrote:
your java works well just check the symlink on /usr/bin/java
ls -ln /usr/bin/java
and use eselct for switching


mudrii & BitJam:

I hear what you are aying, and I agree that java does link to the run-java-tool

Code:
# ls -ln /usr/bin/java
lrwxrwxrwx 1 0 0 13 Jul  5 09:58 /usr/bin/java -> run-java-tool


Just to be clear, I am not saying that java is not working.

If I do a java -version or a which java, it resolves to the right version.

The only issue is that my path is not getting updated.

Code:
 # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin


I do not want /opt/blackdown-jdk-1.4.2.03/bin to be in my path, I instead want my selected jvm

Code:
 # eselect java-vm list
Available Java Virtual Machines:
  [1]   blackdown-jdk-1.4.2
  [2]   sun-jdk-1.5
  [3]   sun-jdk-1.6  system-vm
  [4]   sun-jre-bin-1.6


therefore, I thought my path should contain /opt/sun-jdk-1.6.0.01/bin/java/bin
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Tue Jul 10, 2007 9:58 pm    Post subject: Reply with quote

bump

any further thoughts anyone?
Back to top
View user's profile Send private message
Insanity5902
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1228
Location: Fort Worth, Texas

PostPosted: Wed Jul 11, 2007 1:15 am    Post subject: Reply with quote

That is not how the gentoo java works. It uses a symlink in the /usr/share directory I believe which points to the jvm you want. The one in the PATH is set by java-config-1 I believe, which is used for compiling, which as of right now, gentoo only supports compiling with java 1.4

I believe this is all true, but I am stuck on a windows machine right now so I am not able to verify.
_________________
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Wed Jul 11, 2007 3:24 am    Post subject: Reply with quote

seems to me that the version of java that you are using should be in your path as well
Back to top
View user's profile Send private message
Insanity5902
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1228
Location: Fort Worth, Texas

PostPosted: Wed Jul 11, 2007 4:14 am    Post subject: Reply with quote

Okay, I verfieid it,

Java 1.4 is in the path b/c it is used by portage to emerge applications.

/usr/bin/java -> run-java-tool ... read it, you will see whats going on. javac points to the same file.

It handles the multiple jvm's set by java-config-2. Read it also to understand how it works.

The enviroment vars JAVAC, JAVA_HOME, and JDK_HOME point to satic dirs that again are handle by java-config-2.

to re-iterate. The Gentoo devs have spent a lot of time working on the java-config system to make sure you can run multiple JVM's easily.

I run 1.4 (have to for portage), 1.5, 1.6, 1.6 alpha, 1.7, openjdk 1.7 , I can easily move around to any jvm on the fly, without having to relog in to reset enviroment variables, including PATH. Trust me the dev's worked really hard and the system works really great ... use it and enjoy.
_________________
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
dingfelder
Apprentice
Apprentice


Joined: 27 Jun 2007
Posts: 162
Location: New Zealand

PostPosted: Wed Jul 11, 2007 4:42 am    Post subject: Reply with quote

just to be clear, I do like it and do use it. :)

I have used java-config to set 1.6 as my java version, have read (and like the java-tool script) and it does seem to work.

I have just run into isues where 3rd party apps look for stuff in the path and I am am worried that something will get confused as the current java version is not found there.
Back to top
View user's profile Send private message
Insanity5902
Veteran
Veteran


Joined: 23 Jan 2004
Posts: 1228
Location: Fort Worth, Texas

PostPosted: Wed Jul 11, 2007 5:30 am    Post subject: Reply with quote

If the app is looking for it in the path it is my understanding the app is practicing bad coding habits, they should be looking for the specific java env
_________________
Join the adopt an unanswered post initiative today
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum