免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1190 | 回复: 0
打印 上一主题 下一主题

Linux下的Java环境的搭建 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-03-26 15:18 |只看该作者 |倒序浏览
好久就想玩玩JAVA了,最近有点空闲,开始了自己的JAVA之旅,当然首先是JAVA环境的搭建,我用的是J2SE 5.0,安装在Red Hat Linux7.3下。
好久就想玩玩JAVA了,最近有点空闲,开始了自己的JAVA之旅,当然首先是JAVA环境的搭建,我用的是J2SE 5.0,安装在Red Hat Linux7.3下。
一、SUN提供的安装方档中的部分内容:
Install formats - JDK 5.0 is available in two installation formats.
Self-extracting Binary File - This file can be used to install the JDK in a location chosen by the user. This one can be installed by anyone (not only root users), and it can easily be installed in any location. As long as you are not root user, it cannot displace the system version of the Java platform suppled by Linux. To use this file, see
Installation of Self-Extracting Binary
below. RPM Packages - A rpm.bin file containing RPM packages, installed with the rpm utility. Requires root access to install, and installs by default in a location that replaces the system version of the Java platform supplied by Linux. To use this bundle, see
Installation of RPM File
below. Choose the install format that is most suitable to your needs.
Note: For any text on this page containing the following notation, you must substitute the appropriate JDK update version number for the notation.
For example, if you are downloading update 1.5.0_01, the following command:
./jdk-1_5_0_-linux-i586.bin
would become:
./jdk-1_5_0_01-linux-i586.bin
Installation of Self-Extracting Binary
Use these instructions if you want to use the self-extracting binary file to install the JDK. If you want to install RPM packages instead, see Installation of RPM File.
1. Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle.
You can download to any directory you choose; it does not have to be the directory where you want to install the JDK.
Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.
2. Make sure that execute permissions are set on the self-extracting binary.
Run this command:
chmod +x jdk-1_5_0_-linux-i586.bin
3. Change directory to the location where you would like the files to be installed.
The next step installs the JDK into the current directory.
4. Run the self-extracting binary.
Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with "./" (necessary if "." is not in the PATH environment variable):
./jdk-1_5_0_-linux-i586.bin
The binary code license is displayed, and you are prompted to agree to its terms.
The JDK files are installed in a directory called jdk1.5.0_ in the current directory. Follow this link to see its directory structure. The JDK documentation is a separate download.
Note about Root Access: Unbundling the software automatically creates a directory called jdk1.5.0_. Note that if you choose to install the JDK into system-wide location such as /usr/local, you must first become root to gain the necessary permissions. If you do not have root access, simply install the JDK into your home directory, or a subdirectory that you have permission to write to.
Note about Overwriting Files: If you unpack the software in a directory that contains a subdirectory named jdk1.5.0_, the new software overwrites files of the same name in that jdk1.5.0_ directory. Please be careful to rename the old directory if it contains files you would like to keep.
Note about System Preferences: By default, the installation script configures the system such that the backing store for system preferences is created inside the JDK's installation directory. If the JDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines. As an alternative, root users can use the -localinstall option when running the installation script, as in this example:
jdk-1_5_0_-linux-i586.bin -localinstall
This option causes the system preferences to be stored in the /etc directory from which they can be shared only by VMs running on the local machine. You must be root user for the -localinstall option to work.
See the Preferences API documentation for more information about preferences in the Java platform.
Installation of RPM File
Use these instructions if you want to install JDK in the form of RPM packages. If you want to use the self-extracting binary file instead, see
Installation of Self-Extracting Binary
.
1. Download and check the file size.
You can download to any directory you choose.
Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.
2. Extract the contents of the downloaded file.
Change directory to where the downloaded file is located and run these commands to first set the executable permissions and then run the binary to extract the RPM file:
chmod a+x jdk-1_5_0_-linux-i586-rpm.bin
./jdk-1_5_0_-linux-i586-rpm.bin
Note that the initial "./" is required if you do not have "." in your PATH environment variable.
The script displays a binary license agreement, which you are asked to agree to before installation can proceed. Once you have agreed to the license, the install script creates the file jdk-1_5_0_-linux-i586.rpm in the current directory.
3. Become root by running the su command and entering the super-user password.
4. Run the rpm command to install the packages that comprise the JDK:
rpm -iv jdk-1_5_0_-linux-i586.rpm
5. Delete the bin and rpm file if you want to save disk space.
6. Exit the root shell.
二、安装后的配置
1. 编辑文件/etc/profile,在最后加入:
export JAVA_HOME=/usr/java/jdk1.5.0
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$PATH:$JAVA_HOME/bin
2. 为让新配置生效,运行#source /etc/profile
3. 测试,用文本编辑器写一个java程序来验证,保存在/tmp/myDown目录,文件名:HelloWorld.java,输入如下内容:
public class HelloWorld{
   public static void main(String args[]){
     System.out.println("Hello,Wrold");
   }
}
然后,在终端下执行:
#cd /tmp/myDwon
#javac HelloWorld.java
#java HelloWorld
这时如果出现"Hello,World",就说明你的JAVA编译、运行环境搭建好了。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4789/showart_17830.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP