Ubuntu Install Java JDK and JRE
Ubuntu Linux Install Sun Java Development Kit ( JDK ) and Java Runtime Environment ( JRE )
by Vivek Gite
Q.
How do I install Sun
Java Development Kit (JDK) and Java Runtime Environment (JRE) under
Ubuntu Linux? It appears that there are multiple JRE installed by
default under Ubuntu. How do I select and use Sun JRE only? Can you
explain steps required to set the environment to run java programs or
apps?
A.
Ubuntu Linux 7.10 has following packages from Sun:
=> sun-java6-bin
: Sun Java Runtime Environment (JRE) 6
=> sun-java6-demo
: Sun Java Development Kit (JDK) 6 demos
=> sun-java6-jdk
: Sun Java Development Kit (JDK) 6
=> sun-java6-jre
: Sun Java Runtime Environment (JRE) 6
Install Sun Java 6
Open a shell prompt (terminal) and type the following to install JDK and JRE:
$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
Setup the default Java version
Ubuntu Linux comes with update-java-alternatives utility to updates
all alternatives belonging to one runtime or development kit for the
Java language. To select, Sun's JVM as provided in Ubuntu 7.10, enter:
$ sudo update-java-alternatives -s java-6-sun
You also need to edit a file called /etc/jvm. This file defines the
default system JVM search order. Each JVM should list their JAVA_HOME
compatible directory in this file. The default system JVM is the first
one available from top to bottom. Open /etc/jvm
$ sudo vi /etc/jvm
Make sure /usr/lib/jvm/java-6-sun is added to the top of JVM list
/usr/lib/jvm/java-6-sun
At the end your file should read as follows:
/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr
Save and close the file.
Setup the environment variable
You also need to setup JAVA_HOME and PATH variable. Open your
$HOME/.bash_profile or /etc/profile (system wide) configuration. Open
your .bash_profile file:
$ vi
$HOME/.bashrc
Append following line:
#set java envir
Ïà¹ØÎĵµ£º
¶þ¡¢JavaÀ¬»ø»ØÊÕ
1. JVMÔËÐл·¾³ÖÐÀ¬»ø¶ÔÏóµÄ¶¨Òå
Ò»¸ö¶ÔÏó´´½¨ºó±»·ÅÖÃÔÚJVMµÄ¶ÑÄÚ´æÖУ¬µ±ÓÀÔ¶²»ÔÙÒýÓÃÕâ¸ö¶ÔÏóʱ£¬Ëü½«±»JVMÔÚ¶ÑÄÚ´æÖлØÊÕ¡£»ò µ±¶ÔÏóÔÚJVMÔËÐпռäÖÐÎÞ·¨Í¨¹ý¸ù¼¯ºÏ(root set)µ½´ïʱ£¬Õâ¸ö¶ÔÏó¾Í±»³ÆΪÀ¬»ø¶ÔÏó¡£
2. ¶ÑÄÚ´æ
* ÔÚJVMÆô¶¯Ê±±»´´½¨£»¶ÑÄÚ´æÖÐËù´æ´¢µ ......
1.ÕýÔò±í´ïʽ½á¹¹¼ò½é£º
С֪ʶ£º{}¡¡¶¨ÒåÁËÒ»¸ö·¶Î§¡¡ [] ¶¨ÒåÁËÒ»¸ö×Ö·ûÀà¡¡() ¶¨ÒåÁËÒ»¸ö×é
*Ç°Ãæ³öÏÖ0´ÎÒÔÉÏ +¡¡Ç°ÃæÆ¥ÅäÒ»´ÎÒÔÉÏ¡¡?Ç°Ãæ³öÏÖ0´Î»òÒ»´Î
1).×Ö·û£º
x------×Ö·ûx
\\-----·´Ð±¸Ü
\0n----Ê®½øÖÆÊý (0 <= n <= 7)
\0nn---Ê®½øÖÆÊý0nn (0 <= n <= 7)
\0mnn--Ê®½øÖÆÊý ......
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOM
JAVA²Ù×÷XMLµÄÍêÕûÀý×Ó——W3C DOMƪÊÕ²Ø
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml v ......
Ç×°®µÄ Java ÐÂÊÖÃÇ£º
ºÜ¸ßÐËÄãÃÇÔ¸ÒâÀ´ÕâÀﹲͬѧϰ£¬
Java Õâ¸öÓïÑÔ£¬ÒѾ²»ÔÙÊÇÓïÑÔÁË£¬Ëû¹´ÀÕ³öÒ»¸ö¿ª·ÅʽµÄ¿ª·¢»·¾³£¬
»ù±¾ÉÏ java.sum.com ºÜ´ÖÂÔµØ°Ñ Java ·ÖΪÈý¸ö²¿·Ö£º
(1) J2SE ( Java 2 Standard Edition )
(2) J2EE ( Java 2 Enterprise Edition )
(3) J2ME ( Java 2 Micro Edition ) ......
/*
* @(#)MemoryMonitor.java 1.3 05/11/17
*
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are ......