1. Download a JDK for Linux platform. We recommend that you download the RPM self-extracting 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. 3. The program will automatically generate a j2sdk-1_4_2_06-linux-i586.rpm file, which is the main package, to install below; [Root @ linuxserver RPM] # rpm-IVH j2sdk-1_4_2_06-linux-i586.rpm Preparing... ######################################## ### [100%] 1: j2sdk ####################################### #### [100%] 4. Set Environment Variables Usually, you prefer 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. bashrc 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 the/etc/profile. However, this setting is not recommended because it will take effect for your shell and affect system security. Next, verify whether the variable settings take effect (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/sbin:/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 command below; [Root @ linuxserver text] # javac test. Java [Root @ linuxserver text] # Java Test Hello world! OK. The operation is normal. 6. To allow a user to run Java commands, modify the bash initialization file. For example, to grant longware the permission 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. 8. If you want to take effect under the shell of all users, you can change the. profile file and add 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 Then go to the non-root account and you will be able to execute it. If the shell in your root account is still unavailable, you can change the. bashrc file of the root user, Add $ java_home/bin (: $ java_home/JRE/bin) to the path item) You do not need to add the path in the brackets in the mandrakelinux10 official! You can solve it! |