Java JDK environment variable standard configuration

Source: Internet
Author: User

1. Environment variable Configuration

Environment variables Detailed Description:

51258187

50510178

JDK Installation path:

Some people are installed in:

/usr/local/java/jdk

Some are installed in:

/usr/java/jdk

So export java_home See the path to installing JAVA JDK

Can be configured according to the installation path

Export Java_home=/usr/local/java/jdkexport JAVA_HOME=/USR/JAVA/JDK


Java environment variable----requires only JRE

Vi/etc/profile


#set java environmentexport java_home=/usr/java/jdkexport jre_home= $JAVA _home/jreexport classpath=.: $JAVA _home/lib/ Dt.jar: $JAVA _home/lib/tools.jarexport path= $PATH: $JAVA _home/bin: $JRE _home/bin

Source/etc/profile

2. $jre_home/bin/java before executing Java commands in shell scripts

Run Java command with JRE, minimize

Shell script part content #set java environment#export java_home=/usr/local/java/jdkexport java_home=/usr/java/jdkexport JRE_HOME= $JAVA _home/jre# Execute JAVA command 1:nohup $JRE _home/bin/java-xms256m-xmx512m-jar $JAR _name >/dev/null 2>&1 Execute Java Command 1: $JRE _home/bin/java $JAVA _opts-jar-dconf.path=file:conf/$prog


The script illustrates the following:

#!/bin/sh## java envexport java_home=/usr/local/java/jdk1.7.0_72export jre_home= $JAVA _home /jre## service nameapp_name=userservice_dir=/home/wusc/edu/service/$APP _nameservice_name= edu-service-$APP _namejar_name= $SERVICE _name\.jarpid= $SERVICE _name\.pidcd  $SERVICE _dircase  "$"   In    start)         nohup  $JRE _home/bin/java  -Xms256m -Xmx512m -jar  $JAR _name >/dev/null 2>&1 &         echo $! >  $SERVICE _dir/$PID          echo  "=== start  $SERVICE _name"          ;;     stop)         kill  ' cat  $SERVICE _dir/ $PID '         rm -rf  $SERVICE _dir/$PID          echo  "=== stop  $SERVICE _name"         sleep  5#### edu-service-aa.jar## edu-service-aa-bb.jar         p_id= ' ps -ef | grep -w  "$SERVICE _name"  | grep -v  "grep"  | awk  ' {print $2} '         if [  ' $P _id '  ==  ""  ]; then            echo   "===  $SERVICE _name process not exists or stop success"          else             echo  "===  $SERVICE _name process pid is: $P _id"              echo  "=== begin kill  $SERVICE _name process,  pid is: $P _id " &NBsp;          kill -9  $P _id         fi        ;;     restart)         $0 stop         sleep 2        $0 start         echo  "=== restart  $SERVICE _name"          ;;     *)         ## restart         $0 stop        sleep 2         $0 start        ;; Esacexit 0



Java JDK environment variable standard configuration

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.