[b]Ubuntu 12.04 下安装配置 JDK:[/b]
[url]http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux[/url]
[url]http://blog.csdn.net/yang_hui1986527/article/details/6677450[/url][quote]~/.bashrc 中:
[b]Linux 下 java 相关命令:[/b]
[url]http://docs.oracle.com/javase/6/docs/technotes/tools/[/url]
[url]http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux[/url]
[url]http://blog.csdn.net/yang_hui1986527/article/details/6677450[/url][quote]~/.bashrc 中:
#JDK
export JAVA_HOME=/home/lee/Dev/jdk/jdk1.7.0_07
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
由于 ubuntu 下的系统默认 jdk 是 openjdk,所以其他需要jdk的服务使用的都是 openjdk。为了将其改为自己安装的Sun JDK 1.7,需要做如下配置:
sudo update-alternatives --install /usr/bin/java java /home/lee/Dev/jdk/jdk1.7.0_07/bin/java 300;
sudo update-alternatives --install /usr/bin/javac javac /home/lee/Dev/jdk/jdk1.7.0_07/bin/javac 300;
sudo update-alternatives --install /usr/bin/jar jar /home/lee/Dev/jdk/jdk1.7.0_07/bin/jar 300;
sudo update-alternatives --install /usr/bin/javah javah /home/lee/Dev/jdk/jdk1.7.0_07/bin/javah 300;
sudo update-alternatives --install /usr/bin/javap javap /home/lee/Dev/jdk/jdk1.7.0_07/bin/javap 300;
然后:
sudo update-alternatives --config java
Finally,use java -version to check it:
$ java -version
[/quote]
[b]Linux 下 java 相关命令:[/b]
[url]http://docs.oracle.com/javase/6/docs/technotes/tools/[/url]
# JVM Process Status Tool - Lists instrumented HotSpot Java virtual machines on a target system.
$ jps -lv | less -S
# JVM Statistics Monitoring Tool - Attaches to an instrumented HotSpot Java virtual machine and collects and logs performance statistics as specified by the command line options.
$ jstat -<option> <pid-of-jvm-instance>
# 使用下面的命令查看 jstat 都有哪些可用的 options:
$ jstat -options
# Stack Trace for Java - Prints a stack trace of threads for a given process or core file or remote debug server.
$ jstack <pid-of-jvm-instance>
$ jmap
$ jhat