Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 25051 - Adding Java aliases for java-config
Summary: Adding Java aliases for java-config
Status: RESOLVED WONTFIX
Alias: None
Product: [OLD] Docs-user
Classification: Unclassified
Component: Gentoo Java Guide (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Sven Vermeulen (RETIRED)
URL: http://www.gentoo.org/doc/en/java.xml
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-22 06:04 UTC by tom
Modified: 2003-08-29 02:03 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tom 2003-07-22 06:04:39 UTC
So Java runs in a similar fashion to other *NIX systems I have added aliases for java and javac so they work with the VM set in java config.As you want to run the command echoed by java-config --java as your alias instead of the actual command itself you have to put it in command-quotes inside single-quotes:

alias java='`java-config --java`'
alias javac='`java-config --javac`'

This works with bash and should work with other shells which support aliases. You then use java and javac as you normally would:

javac JavaApp.java
java JaavaApp





Reproducible: Always
Steps to Reproduce:

1.alias java='`java-config --java`'
2.alias javac='`java-config --javac`'
3.alias

Actual Results:  
...
alias java='`java-config --java`'
alias javac='`java-config --javac`'
...


Expected Results:  
As expected

Needs java-config and a Java VM to be installed and set. 
Alias should overwrite any java or javac commands in your $PATH

$ bash --version
GNU bash, version 2.05b.0(1)-release (i586-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

Karl Trygve Kalleberg has asked for this bug to be assigned to him.
Comment 1 Sven Vermeulen (RETIRED) gentoo-dev 2003-08-28 10:26:15 UTC
Actually at my system "java-config --java" and "which java" return the same. I see no reason for the users to create an alias for java if it works.
Comment 2 tom 2003-08-29 01:16:23 UTC
Hi

I'm assuming this is because you've got the correct java directory in your
PATH, which isn't there by default becasue it goes in /opt/. Thinking about
it a better way of doing it without using aliases is to add the correct java
dir to your PATH. This way all the java binaries, including appletviewer
etc., will point to the correct ones. I've added this to my ~/.bash_profile:


PATH=/dirs/in/path

JAVAPATH=`java-config --jdk-home`/bin

PATH=${PATH}:${JAVAPATH}

export PATH



Without a java dir in your path `which java` gives the error:

which: no java in (/dirs/in/path)

This ensures that you're always using the correct java, appletviewer, etc.
as long as you remember to `. ~/.bash_profile` after you change the jdk with
java-config.
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2003-08-29 02:03:03 UTC
The java binaries are placed inside their /opt directories, and the PATH variable is extended with that directory (check /etc/env.d/20java and /etc/env.d/30java-finalclasspath). 

Installing java automatically sets those stuff. If some java ebuild doesn't do that, then that's an error of the ebuild.