By default, Fedora Core 6 systems come with an old Java software installed, so you need to install a newer version of Java Runtime Environment to enjoy all the Java applications out there. In this quick guide, I will teach you how to update/install your Java Environment.
Let's begin by downloading the latest version of JRE (Java Runtime Environment) from here. Just click on the Download link where it says Java Runtime Environment (JRE) 5.0 Update, then you’ll need to accept the license and download the Linux self-extracting file.
WARNING: Please remember to always replace the xx from the jre-1_5_0_xx-linux-i586.bin file with the latest version. At the moment of this guide’s writing, the latest version was 09, so the file should look like this: jre-1_5_0_09-linux-i586.bin
After you have finished downloading the file, you need to move it into the /opt folder. Open a console and type:
mv jre-1_5_0_xx-linux-i586.bin /opt
Now, you will need to make this file executable so you can extract it. Follow the commands below:
cd /opt - so you can go into the /opt directory
chmod +x jre-1_5_0_xx-linux-i586.bin
And now, let's run the executable file with the following command:
./jre-1_5_0_xx-linux-i586.bin
You'll be prompted with the License Agreement, hit space until you are asked if you agree or not. Type Yes and the extraction process will begin. After the extraction process is finished, just remove the binary file with the following command:
rm -rf jre-1_5_0_xx-linux-i586.bin
Now, let's put the Java plugin into your browser's plugin folder. Konqueror, Firefox and Mozilla browsers will all look into the same folder, for plugins. So type the following command:
ln -s /opt/jre1.5.0_xx/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
Well, now you need to make the Java executable available for the whole system, so you can run all the Java applications you encounter. Create the following file with your preferred text editor:
kwrite /etc/profile.d/java.sh
Now paste the following options into the file, remember to enter a carriage return after these lines, then save it. Remember to replace the xx with the latest version you have downloaded:
export J2RE_HOME=/opt/jre1.5.0_xx
export PATH=$J2RE_HOME/bin:$PATH
Now, type the following command to make that file available:
source /etc/profile.d/java.sh
Then type this command to see if the path is correct:
which java
You will see something like this: /opt/jre1.5.0_09/bin/java
Then type these commands:
/usr/sbin/alternatives --install /usr/bin/java java /opt/jre1.5.0_xx/bin/java 2
/usr/sbin/alternatives --config java
After you have entered the last command, you'll be asked to choose which Java software you want for your system. Just press 2 key and hit enter.
And finally, just type this command to see if everything looks good and your system has a new Java Environment:
/usr/sbin/alternatives --display java
And you can also type this command to see the version of your Java Runtime Environment:
java -version
Mine looks like this:
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b01)
Java HotSpot(TM) Client VM (build 1.5.0_09-b01, mixed mode, sharing)
You should now be able to run most of the Java applications out there, with the commands like:
java -jar application.jar
or
javaws application.jnlp
Enjoy!
RELATED LINKS
How to Install XGL on Fedora Core
Fedora Desktop Customization
Debian Installation Guide
Installing A Linux Distro to An USB Drive
Flash Player for Linux
Configuring the Ethernet Interface from The Command Line
How-to Use Your Partitions in Linux
-------------------------------------------------------------------------------------------------------------
安装和配置 Java J2SE Development Kit(JDK)
http://fedora.linuxsir.org/main/?q=node/97整理:懒猫 [ stephencat AT 126.com ],整理于 2005 年 10 月 14 日。
来自:LinuxSir.Org
摘要:不少用户希望使用 Sun Java JDK/JRE 代替系统自带和默认使用的 Java虚拟机 GCJ 来运行、调试 Java 应用程序。本文将为您解决这个问题。
适用发行版:使用 GCJ 作为默认 Java 环境的发行版,如 Fedora Core 4
主要内容索引
- 安置 Java
- 创建快捷方式以取代 GCJ
- 配置环境变量
- 优化中文显示
- 配置浏览器插件
- JAVA 控制台的调用
一、下载JDK
1. 下载
从这里可以找到最新的 JDK:
http://java.sun.com/
根据自己的机器来下载对应的版本,例如
jdk-1_5_0_05-linux-i586.bin
这是 J2SE Development Kit 1.5 update 5 for Linux 的 sh 自解压执行脚本。里面已经包含安装压缩包。
2、释放软件包
查看当前目录下所有文件
[root@localhost sunjava]# ls
jre-1_5_0_04-linux-i586.bin
执行 sh 自解压脚本
[root@localhost sunjava]# sh jre-1_5_0_04-linux-i586.bin
Do you agree to the above license terms? [yes or no] yes
再次查看当前目录下所有文件
[root@localhost sunjava]# ls
jre1.5.0_04 jre-1_5_0_04-linux-i586.bin
事实上 sh 脚本会自释放一个 名为 jdk1.5.0_05 的文件夹到当前目录下
二、配置 Java 编译、运行环境
1. 安置 Java
把 jdk1.5.0_05 文件夹移动(或者复制)到 /usr/local 目录中
[root@localhost sunjava]# mv jdk1.5.0_05 /usr/local/
2. 创建快捷方式以取代 GCJ
制作 java 和 javac 的快捷方式(静态链接),以代替 gcj。
#cd /usr/bin
#ln -s -f /usr/local/jdk1.5.0_05/jre/bin/java
#ln -s -f /usr/local/jdk1.5.0_05/bin/javac
ln 命令的 -f 参数的作用是强制覆盖原来已经存在的 /usr/local/java 静态链接文件。由于 jdk 目录下的 bin 文件夹内容可以代替 /jdk1.5.0_05/jre/bin 的内容,因而也可以直接使用 /jdk1.5.0_05/bin 这个路径。
注意:这个步骤并没有把 GCJ 从您的电脑中彻底删除。您仍然可以使用 whereis gcj 命令找到它,并在需要的时候使用它。
3. 配置环境变量
方法一:独立终端用户的个性化配置
编辑当前用户的.bashrc,即:
$gedit ~/.bashrc
或者
#gedit /home/xxxx/.bashrc
加入如下五行:
JAVA_HOME=/usr/local/jdk1.5.0_05
JAVA_BIN=/usr/local/jdk1.5.0_05/bin
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
方法二:适用于所有用户 (未经测试)
#gedit /etc/profile.d/java.sh
文件内容如下:
export JAVA_HOME=/usr/local/jdk1.5.0_05
export JAVA_BIN=/usr/local/jdk1.5.0_05/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
4. 优化中文显示
加一个字体simsun.ttf
在 /usr/local/jdk1.5.0_05/lib 中建立文件夹 fonts ,再在其下建立文件夹 fallback
在 /usr/local/jdk1.5.0_05/jre/lib/fonts/ 中建立文件夹 fallback
然后拷字体 simsun.ttf 到这两个目录,或者把simsun.ttc 复制成simsun.ttf也行,然后放到这两个目录
5. 配置浏览器插件
这里介绍安装 Java 的浏览器支持插件。
比如我用 firefox 浏览器,则为libjavaplugin_oji.so建一个链接到firefox 相对应的目录中的plugins 目录中,其它浏览器同理;
[root@localhost plugins]# cd /usr/lib/firefox-1.0.6/plugins/
# ln -s /usr/local/jdk1.5.0_05/jre/plugin/i386/ns7/libjavaplugin_oji.so .
6. JAVA 控制台的调用
[someuser@localhost ~]# /usr/local/jdk1.5.0_05/jre/bin/ControlPanel
后记
本文内容大部分来自:《JRE 安装和配置,以适合JAVA程序运行所具备的环境》(作者:北南南北) ,再结合论坛讨论结果整理完成,在 Fedora Core 4 上测试通过。