Configuring a Java development environment under Linux [transferred from http:chenzhe.blogchina.com]

xiaoxiao2021-03-06  42

1. Go to http://java.sun.com/j2se/1.4.2/download.html download a Linux Platform's JDK, it is recommended to download RPM self-demired format (RPM IN Self-extracting file, J2SDK-1_4_2_06-Linux- I586-rpm.bin; 2. Upload to the Linux server, execute the command under the 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 will have a SUN protocol, knock a few spaces, when you ask if you agree, you can use it. Sun Microsystems, Inc. Binary Code License Agreement for the 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 execute directly The unzip command is also possible, in short, it is possible to get an RPM package. 3. The program will automatically generate a J2SDK-1_4_2_06-Linux-I586.rpm file, which is the main program package, below; [root @ linuxserver rpm] # RPM-IVH J2SDK-1_4_2_06-Linux-i586.rpm preplay ... ################################################################# ######### [100%] 1: j2sdk ################################################################################################################################################################################################################################################# ######## [100%] 4. Setting up environment variables usually like to use the export command directly under the shell [root @ Linuxserver rpm] # @ ot 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] # evted path = $ PATH: $ java_home / bin Of course this setting environment variable is It can take effect, but only take effect on the current shell. If you log in from another Shell, you will not be able to use the variables 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 extra set classpath =.: $ java_home / lib / dt.jar: $ JAVA_HOME / lib / Tools.jar Export ClassPath can of course also be implemented by changing / etc / profile, but do not recommend this, because such settings will take effect on the user's shell, affect the system security. That is in this file, the last plus: 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 Let's verify that the variable setting is effective (#### Note: Logout before verification, then log in); [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. Environment Setting OK, see if JDK works properly, 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 Exit, below to compile, execute; [root @ linuxserver text] # javac test.java [root @ linuxserv Er text] # Java Test Hello World! OK, work is working. 6. If you want a user with permissions to run the java command, just modify its Bash initialization file.

转载请注明原文地址:https://www.9cbs.com/read-66556.html

New Post(0)