How to Install Java in Fedora Core 6

http://news.softpedia.com/news/How-to-Install-Java-in-Fedora-Core-6-39724.shtml

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.

<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> width="300" scrolling="no" height="250" frameborder="0" name="google_ads_frame" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-2364887827571271&dt=1164641077230&lmt=1164641066&prev_fmts=728x90_as%2C728x15_0ads_al&format=300x250_as&output=html&channel=0631152740&pv_ch=0631152740%2B&url=http%3A%2F%2Fnews.softpedia.com%2Fnews%2FHow-to-Install-Java-in-Fedora-Core-6-39724.shtml&color_bg=FFFFFF&color_text=677695&color_link=34538C&color_url=34538C&color_border=E1EBFF&ad_type=text_image&ref=http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dfedora%2Bcore%2B6%2Bjava%26btnG%3D%25E6%2590%259C%25E7%25B4%25A2%26hl%3Dzh-CN%26newwindow%3D1&cc=98&u_h=768&u_w=1024&u_ah=744&u_aw=1024&u_cd=24&u_tz=480&u_his=1&u_java=true&u_nplug=1&u_nmime=1" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true">
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 上测试通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值