How to install Java Linux in Linux and Windows

Source: Internet
Author: User
From http://blog.chinaunix.net/space.php? Uid = 20464521 & Do = Blog & id = 1673171linux and Windows install Java Linux
1. Go to the http://java.sun.com/j2se/1.4.2/download.html to download a Linux platform JDK, it is recommended to download RPM self-extract format (rpm in self-extracting file, j2sdk-1_4_2_06-linux-i586-rpm. Bin ).
  
2. Upload the file to a Linux server and run the following command in shell:
  
[Root @ linuxserver RPM] #
Chmod 755 j2sdk-1_4_2_06-linux-i586-rpm.bin
[Root @ linuxserver RPM] #
/J2sdk-1_4_2_06-linux-i586-rpm.bin
  
There will be a piece of Sun Protocol, several times the Space key, when asked whether to agree, you can press Yes.
  
Sun Microsystems, Inc.
Binary Code License Agreement
For
Javatm 2 software development kit
(J2sdk), Standard
Edition, version 1.4.2 _ x
...
Do you agree to the above
License terms? [Yes or No] Yes
Unpacking...
Checksumming...
0
0
Extracting...
Unzipsfx 5.40 of 28 November 1998,
By Info-zip (Zip-Bugs@lists.wku.edu ).
Inflating: j2sdk-1_4_2_06-linux-i586.rpm
Done.
  
Note: If you run the unzip command directly to decompress the package, you can obtain an RPM package.
  
3, the program will automatically generate a j2sdk-1_4_2_06-linux-i586.rpm file, this is the main package, the following to install:
  
[Root @ linuxserver RPM] # rpm-IVH
J2sdk-1_4_2_06-linux-i586.rpm
Preparing ...######################
##################### [100%]
1: j2sdk ########################
################### [100%]
  
4. Set Environment Variables
  
You usually like to use the Export command to directly set it in shell:
  
[Root @ linuxserver RPM] #
Export java_home =/usr/Java/j2sdk1.4.2 _ 06
[Root @ linuxserver RPM] #
Export classpath =.: $ java_home/lib/dt. jar:
$ Java_home/lib/
Tools. Jar
[Root @ linuxserver RPM] #
Export Path = $ path: $ java_home/bin
  
Of course, this setting of environment variables takes effect only for the current shell. If you log on from another shell, you cannot use the variable you just set. So the best way is to modify the. bashr C file.
  
[Root @ linuxserver RPM] # vi. bashrc
Set java_home =/usr/Java/j2sdk1.4.2 _ 06
Export java_home
Set Path = $ path: $ java_home/bin
Export path
Set classpath =.: $ java_home/lib/dt. jar:
$ Java_home/lib/tools. Jar
Export classpath
  
Of course, you can also change/etc/profile, but this is not recommended,
  
This setting will take effect for the user's shell and affect system security.
  
Add the following at the end of the file:
  
Export java_home =/usr/Java/j2sdk1.4.2 _ 06
  
Export classpath =.: $ java_home/lib/dt. Jar
  
: $ Java_home/lib/tools. Jar
  
Export Path = $ path: $ java_home/bin
  
Next, let's verify whether the variable settings take effect (#### Note: log out before verification, and then log on again ):
  
[Root @ linuxserver RPM] #
Echo $ java_home
/Usr/Java/j2sdk1.4.2 _ 06/
[Root @ linuxserver RPM] #
Echo $ classpath
/Usr/Java/j2sdk1.4.2 _ 06/lib/dt. jar:
/Usr/Java/j2sdk1.4.2 _ 06/lib/tools. Jar
[Root @ linuxserver RPM] #
Echo $ path
/Usr/Java/j2sdk1.4.2 _ 06/bin /:
/Usr/Kerberos/sbin:/usr/Kerberos/bin:
/Usr/local/SBI
N:
/Usr/local/bin:/sbin:/bin:/usr/sbin:
/Usr/bin:/usr/x11r6/bin:/root/bin
[Root @ linuxserver RPM] # Java-version
Java version "1.4.2 _ 06"
Java (TM) 2 Runtime Environment,
Standard Edition (build 1.4.2 _ 06-b03)
Java hotspot (TM) Client
VM (build 1.4.2 _ 06-b03, mixed mode)
  
5. Set the environment to OK to see if JDK works normally. Let's write a test file test. Java:
  
[Root @ linuxserver RPM] # VI test. Java
Class Test
{
Public static void main (string [] ARGs)
{
System. Out. println ("Hello world! ");
}
}
  
Save and exit. Compile and execute the following code:
  
[Root @ linuxserver text] # javac test. Java
[Root @ linuxserver text] # Java Test
Hello world!
  
Okay, it works normally.
  
6. To allow a user to run Java commands, modify the bash initialization file. For example, longware has the following permissions to run Java commands:
  
[Root @ linuxserver root] #
VI/home/longware/. bashrc
Set java_home =/usr/Java/j2sdk1.4.2 _ 06
Export java_home
Set Path = $ path: $ java_home/bin
Export path
Set classpath =.: $ java_home/lib/dt. jar:
$ Java_home/lib/tools. Jar
Export classpath
  
7. Now, JDK installation on Linux is complete. Extract To/OPT.
  
8. Write a script to start eclipse
  
#! /Bin/bash
#
# Execute eclipse 3
#
Export java_home =/usr/Java
/J2sdk1.4.2 _ 06
Export classpath =/usr/Java
/J2sdk1.4.2 _ 06/lib
/Opt/Eclipse/eclipse-VM/usr/Java
/J2sdk1.4.2 _ 06/bin/Java-data/home/chenzhe/WO
Rkspace &
  
#-VM parameters are used to specify which JVM is used to execute eclipse,
  
# The-date parameter is used to specify the eclipse data directory.
  
Save the script to/usr by specifying that it exists in the workspace directory under the user root directory (/home/chenzhe /).
  
/Local/bin, called eclipse, and assigned 755 permissions to eclipse
  
9. Create a starter on the desktop. Select an icon and set the path to/opt/Eclipse/eclipse and/OP.
  
T/Eclipse/icon. XPM is the eclipse icon.
  
10. Double-click the icon or enter eclipse on the terminal!
 
 
 
How to install Windows
To download and install JDK, follow these steps:
  
1. Click the following URL to go to The jdk1.4 download page:
  
Http://java.sun.com/j2se/1.4.2/download.html
  
2. Click "Download j2se SDK ":

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.