Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3178745
  • 博文数量: 797
  • 博客积分: 10134
  • 博客等级: 上将
  • 技术积分: 9335
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-22 22:57
个人简介

1

文章分类

全部博文(797)

文章存档

2022年(1)

2021年(2)

2017年(2)

2016年(1)

2015年(4)

2014年(1)

2013年(6)

2012年(6)

2011年(10)

2010年(26)

2009年(63)

2008年(61)

2007年(51)

2006年(563)

我的朋友

分类: LINUX

2006-09-22 11:31:04

安装和配置 JPackage Java

作者:Paul Howarth(懒猫译) 来源:linuxsir.org (2006-04-17 16:48:05)

摘要:FC4 的发行说明中建议用户尽量避免直接使用 Sun 提供的 Java RPM,并提供了从 JPackage.org 构建 Java 的途径。本文向您介绍安装 JPackage Java 的详细步骤和注意事项。

在 Fedora Core 4 发行说明中的 Java 软件包建议的基础上,本文将逐步向你介绍从 jpackage.org 中为 FC4 构建 Java 软件包的详细方法。

6.1.8 Java 软件包建议

我们不建议 Fedora Core 4 的用户使用由 Sun 提供的 Java RPM。因为它跟由 Fedora Core 4 提供的软件包所使用的名字冲突。因此,Sun Java 可能会在对系统软件包进行升级操作的过程中消失掉。建议 Fedora Core 4 的用户要不使用来自 jpackage.org 的 RPM,要不自己手动把 Sun Java tarball 压缩包安装到 /opt 里。为了系统稳定,推荐您使用 Sun Java 1.5 或以上的版本。

内容索引

  • 从 Fedora Extras 扩展软件源安装 fedora-rpmdevtools
  • 构建 rpmbuild 树
  • 从 JPackage 安装 jpackage.repo 资源列表
  • 从 Sun 下载 jdk-1_5_0_05-linux-i586.bin
  • 把 jdk-1_5_0_05-linux-i586.bin 复制到 SOURCES 文件夹
  • 从 JPackage 下载 java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm
  • 构建 java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm
  • 当遇到不正确的 rpath 问题的解决办法
  • 安装 Java 软件包
  • 当遇到未签名软件包时的解决办法
  • 检查 Java 版本
  • Firefox 浏览器插件
  • 切换不同的 Java 版本

从 Fedora Extras 扩展软件源安装 fedora-rpmdevtools

[localhost ~]$ sudo yum install fedora-rpmdevtools
Setting up Install Process
Setting up repositories
updates-released 100% |=========================| 951 B 00:01
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for fedora-rpmdevtools to pack into transaction set.
fedora-rpmdevtools-1.1-1. 100% |=========================| 20 kB 00:00
---> Package fedora-rpmdevtools.noarch 0:1.1-1.fc4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
 Package Arch Version Repository Size
=============================================================================
Installing:
 fedora-rpmdevtools noarch 1.1-1.fc4 extras 59 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 59 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): fedora-rpmdevtools 100% |=========================| 59 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: fedora-rpmdevtools ######################### [1/1]
Installed: fedora-rpmdevtools.noarch 0:1.1-1.fc4
Complete!
[localhost ~]$
 

构建 rpmbuild 树

[localhost ~]$ fedora-buildrpmtree
[localhost ~]$ ls
Desktop download rpmbuild
[localhost ~]$

从 JPackage 安装 jpackage.repo 资源列表

[localhost ~]$ cd /etc/yum.repos.d/
[localhost yum.repos.d]$ sudo wget
--11:38:19--
           => `jpackage.repo'
Resolving 212.85.153.228
Connecting to [212.85.153.228]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 629 [text/plain]
100%[======================================================>] 629 --.--K/s
11:38:20 (1.30 MB/s) - `jpackage.repo' saved [629/629]
[localhost yum.repos.d]$
 

从 Sun 下载 jdk-1_5_0_05-linux-i586.bin

1) 浏览
2) 点击 Download JDK 5.0 Update 5
3) 点击 Accept Liecence Agreement
4) 通过点击 Linux self-extracting file 下载 jdk-1_5_0_05-linux-i586.bin

把 jdk-1_5_0_05-linux-i586.bin 复制到 SOURCES 文件夹

你可能会使用别的下载文件夹。

[localhost ~]$ cd download/
[localhost download]$ ls
jdk-1_5_0_05-linux-i586.bin
[localhost download]$ cp jdk-1_5_0_05-linux-i586.bin ~/rpmbuild/SOURCES/
[localhost download]$
 

从 JPackage 下载 java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm

[localhost ~]$ cd download
[localhost download]$ wget
--11:24:23--
           => `java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm'
Resolving mirrors.dotsrc.org... 130.225.247.87
Connecting to mirrors.dotsrc.org[130.225.247.87]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15,807 [application/x-redhat-package-manager]
100%[==================================================================================>] 15,807 11.42K/s
11:24:25 (11.41 KB/s) - `java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm' saved [15,807/15,807]
[localhost download]$
 

构建 java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm

[localhost download]$ rpmbuild --rebuild java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm
Installing java-1.5.0-sun-1.5.0.05-1jpp.nosrc.rpm
warning: InstallSourcePackage: Header V3 DSA signature: NOKEY, key ID c431416d
warning: user jacorley does not exist - using root
warning: group ncsu does not exist - using root
warning: user jacorley does not exist - using root
warning: group ncsu does not exist - using root
warning: user jacorley does not exist - using root
warning: group ncsu does not exist - using root
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.18245
+ umask 022
+ cd /home/phowarth/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ rm -rf /home/phowarth/rpmbuild/BUILD/jdk1.5.0_05
+ export MORE=10000
+ MORE=10000
+ sh /home/phowarth/rpmbuild/SOURCES/jdk-1_5_0_05-linux-i586.bin
...
omitted
...
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-devel-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-demo-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-plugin-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-fonts-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-alsa-1.5.0.05-1jpp.i586.rpm
Wrote: /home/phowarth/rpmbuild/RPMS/i586/java-1.5.0-sun-jdbc-1.5.0.05-1jpp.i586.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.26052
+ umask 022
+ cd /home/phowarth/rpmbuild/BUILD
+ cd jdk1.5.0_05
+ rm -rf /var/tmp/java-1.5.0-sun-1.5.0.05-1jpp-buildroot
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.26052
+ umask 022
+ cd /home/phowarth/rpmbuild/BUILD
+ rm -rf jdk1.5.0_05
+ exit 0
[localhost download]$
 

当遇到不正确的 rpath 问题的解决办法

如果你遇到了下面的错误信息:

+ /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/heapTracker/lib/libheapTracker.so' contains an invalid rpath
'$ORIGIN/../../../../lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/heapTracker/lib/libheapTracker.so' contains an invalid rpath
'$ORIGIN/../../../../jre/lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/heapTracker/lib/libheapTracker_g.so' contains an invalid rpath
'$ORIGIN/../../../../lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/heapTracker/lib/libheapTracker_g.so' contains an invalid rpath
'$ORIGIN/../../../../jre/lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/mtrace/lib/libmtrace.so' contains an invalid rpath
'$ORIGIN/../../../../lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/mtrace/lib/libmtrace.so' contains an invalid rpath
'$ORIGIN/../../../../jre/lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/mtrace/lib/libmtrace_g.so' contains an invalid rpath
'$ORIGIN/../../../../lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
ERROR: file '/usr/share/java-1.5.0-sun/demo/jvmti/mtrace/lib/libmtrace_g.so' contains an invalid rpath
'$ORIGIN/../../../../jre/lib/i386' in [$ORIGIN/../../../../lib/i386:$ORIGIN/../../../../jre/lib/i386]
error: Bad exit status from /var/tmp/rpm-tmp.68469 (%install)
 
那么在 ~/.rpmmacros 文件中把包含“check-rpaths”的那一行注释掉,然后再试一遍。
%_topdir %(echo $HOME)/rpmbuild
%_smp_mflags -j3
#%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
 

安装 Java 软件包

[localhost ~]$ cd ~/rpmbuild/RPMS/i586/
[localhost i586]$ ls -1
java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-alsa-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-demo-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-devel-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-fonts-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-jdbc-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-plugin-1.5.0.05-1jpp.i586.rpm
java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm
[localhost i586]$ sudo yum localinstall *.rpm
Setting up Local Package Process
Examining java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-alsa-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-alsa - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-demo-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-demo - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-devel-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-devel - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-fonts-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-fonts - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-jdbc-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-jdbc - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-plugin-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-plugin - 1.5.0.05-1jpp.i586
Examining java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm: java-1.5.0-sun-src - 1.5.0.05-1jpp.i586
Marking java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-alsa-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-demo-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-devel-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-fonts-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-jdbc-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-plugin-1.5.0.05-1jpp.i586.rpm to be installed
Marking java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm to be installed
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package java-1.5.0-sun-src.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-alsa.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-devel.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-plugin.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-fonts.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-jdbc.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun.i586 0:1.5.0.05-1jpp set to be updated
---> Package java-1.5.0-sun-demo.i586 0:1.5.0.05-1jpp set to be updated
--> Running transaction check
Setting up repositories
extras 100% |=========================| 1.1 kB 00:00
updates-released 100% |=========================| 951 B 00:00
base 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
Finished
--> Processing Dependency: /usr/lib/libodbcinst.so for package: java-1.5.0-sun-jdbc
Importing Additional filelist information for dependency resolution
filelists.xml.gz 100% |=========================| 2.3 MB 00:00
extras : ################################################## 2324/2324
Added 671 new packages, deleted 3 old in 13.91 seconds
filelists.xml.gz 100% |=========================| 2.9 MB 00:00
updates-re: ################################################## 966/966
Added 484 new packages, deleted 486 old in 32.98 seconds
--> Processing Dependency: /usr/lib/libodbc.so for package: java-1.5.0-sun-jdbc
Importing Additional filelist information for dependency resolution
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Package unixODBC.i386 0:2.2.11-3.FC4.1 set to be updated
---> Package unixODBC-devel.i386 0:2.2.11-3.FC4.1 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
 Package Arch Version Repository Size
=============================================================================
Installing:
 java-1.5.0-sun i586 1.5.0.05-1jpp java-1.5.0-sun-1.5.0.05-1jpp.i586.rpm 84 M
 java-1.5.0-sun-alsa i586 1.5.0.05-1jpp java-1.5.0-sun-alsa-1.5.0.05-1jpp.i586.rpm 64 k
 java-1.5.0-sun-demo i586 1.5.0.05-1jpp java-1.5.0-sun-demo-1.5.0.05-1jpp.i586.rpm 14 M
 java-1.5.0-sun-devel i586 1.5.0.05-1jpp java-1.5.0-sun-devel-1.5.0.05-1jpp.i586.rpm 12 M
 java-1.5.0-sun-fonts i586 1.5.0.05-1jpp java-1.5.0-sun-fonts-1.5.0.05-1jpp.i586.rpm 2.0 M
 java-1.5.0-sun-jdbc i586 1.5.0.05-1jpp java-1.5.0-sun-jdbc-1.5.0.05-1jpp.i586.rpm 66 k
 java-1.5.0-sun-plugin i586 1.5.0.05-1jpp java-1.5.0-sun-plugin-1.5.0.05-1jpp.i586.rpm 1.9 M
 java-1.5.0-sun-src i586 1.5.0.05-1jpp java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm 17 M
Installing for dependencies:
 unixODBC i386 2.2.11-3.FC4.1 updates-released 859 k
 unixODBC-devel i386 2.2.11-3.FC4.1 updates-released 811 k
Transaction Summary
=============================================================================
Install 10 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 132 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): unixODBC-2.2.11-3. 100% |=========================| 859 kB 00:00
(2/2): unixODBC-devel-2.2 100% |=========================| 811 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: java-1.5.0-sun ####################### [ 1/10]
  Installing: unixODBC ####################### [ 2/10]
  Installing: unixODBC-devel ####################### [ 3/10]
  Installing: java-1.5.0-sun-src ####################### [ 4/10]
  Installing: java-1.5.0-sun-alsa ####################### [ 5/10]
  Installing: java-1.5.0-sun-devel ####################### [ 6/10]
  Installing: java-1.5.0-sun-plugin ####################### [ 7/10]
  Installing: java-1.5.0-sun-fonts ####################### [ 8/10]
  Installing: java-1.5.0-sun-jdbc ####################### [ 9/10]
  Installing: java-1.5.0-sun-demo ####################### [10/10]
Installed: java-1.5.0-sun.i586 0:1.5.0.05-1jpp java-1.5.0-sun-alsa.i586 0:1.5.0.05-1jpp java-1.5.0-sun-demo.i586 0:1.5.0.05-1jpp java-1.5.0-sun-devel.i586 0:1.5.0.05-1jpp java-1.5.0-sun-fonts.i586 0:1.5.0.05-1jpp java-1.5.0-sun-jdbc.i586 0:1.5.0.05-1jpp java-1.5.0-sun-plugin.i586 0:1.5.0.05-1jpp java-1.5.0-sun-src.i586 0:1.5.0.05-1jpp
Dependency Installed: unixODBC.i386 0:2.2.11-3.FC4.1 unixODBC-devel.i386 0:2.2.11-3.FC4.1
Complete!
[localhost i586]$
 

当遇到未签名软件包时的解决办法

如果你遇到某些情况类似于 Package java-1.5.0-sun-src-1.5.0.05-1jpp.i586.rpm 软件包未签名,并且使用 yum 没有安装到任何 Java 软件包,那么尝试在 /etc/yum.conf 中临时把含有 gpgcheck 的那一行注视掉。

这很正常,因为这些软件包是在本地编译的,它们没有经过 JPackage 构建系统签名。

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
#gpgcheck=1
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
 

不要忘了在安装完软件包以后把 gpgcheck 那一行去掉注释哦。

检查 Java 版本

[localhost i586]$ java -version
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
[localhost i586]$
 

Firefox 浏览器插件

如果你已经安装了 java-1.5.0-sun-plugin 插件支持软件包,并且希望 firefox 使用它,你需要自己手动设置它的静态链接,因为 java-1.5.0-sun-plugin 软件包中有一个小 bug 导致它不能正确地为 FC4 firefox 软件包设置链接。

[localhost i586]$ cd /usr/lib/firefox-1.0.7/plugins
[localhost plugins]$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/plugin/i386/ns7/libjavaplugin_oji.so .
 

作为选择,你可以只是把静态链接放到 /usr/lib/mozilla/plugins 中,这样 mozilla 和 firefox 就都可以一起使用这个插件了,并且在浏览器升级了以后仍然有效哦。

[localhost i586]$ cd /usr/lib/mozilla/plugins
[localhost plugins]$ sudo rm -f libjavaplugin_oji.so
[localhost plugins]$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/plugin/i386/ns7/libjavaplugin_oji.so .
 

仅当你以前曾经安装过别的版本的 java 才需要移除已经存在的 libjavaplugin_oji.so 的静态链接。

切换不同的 Java 版本

JPackage Java RPM 支持使用“alternatives”系统让你可以在不同版本的 Java 之间切换使用。

[localhost ~]$ sudo /usr/sbin/alternatives --config java
There are 3 programs which provide 'java'.
  Selection Command
-----------------------------------------------
   1 /usr/share/java/libgcj-java-placeholder.sh
   2 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 3 /usr/lib/jvm/jre-1.5.0-sun/bin/java
Enter to keep the current selection[+], or type selection number: 2
[localhost ~]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.0.0 20050519 (Red Hat 4.0.0-8)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[localhost ~]$ sudo /usr/sbin/alternatives --auto java
[localhost ~]$ java -version
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
阅读(692) | 评论(0) | 转发(0) |
0

上一篇:CENTOS4配置JSP教程

下一篇:安装JDK- -

给主人留下些什么吧!~~