Installing Java

From Funtoo
Revision as of 22:15, 27 October 2013 by Duncan.Britton (Talk | contribs)

Jump to: navigation, search


What is Java? What purpose does it serve?


"Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!" (ttp:// Oracle page on Java])

Installing java

Editing your make.conf

To tell portage that we would like java pulled in the next time it is updated, we need to do the following:

 # nano /etc/portage/make.conf

Running that command should present you with a file containing something similar to this:

File:Make conf example.png
An example make.conf

In the file, if it does not exist, create a line like the following:


Press Ctrl+X , then y, then enter to write the changes to the file.

Emerging java

To install java, run the following command:

 # emerge --ask --update --newuse --deep @world

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-java/java-config-wrapper-0.16  8 kB
[ebuild  N     ] sys-apps/baselayout-java-0.1.0  71 kB
[ebuild  N     ] dev-java/java-config-2.2.0-r1000:2  PYTHON_ABIS="2.7 3.3 -2.6 -3.1 -3.2 (-3.4)" 51 kB
[ebuild  N     ] app-admin/eselect-java-0.1.0  71 kB
[ebuild  N     ] dev-java/icedtea-bin-  USE="X alsa cups -cjk -doc -examples -nsplugin -source" 47,781 kB
[ebuild  N     ] virtual/jdk-1.7.0:1.7  0 kB
[ebuild  N     ] virtual/jre-1.7.0:1.7  0 kB
Would you like to merge these packages? [Yes/No] yes

Testing to see if it emerged

To check that java installed on your system, run the following command:

java -version

If you get something like this, you are ready to use java!:

java version "1.7.0_21"OpenJDK Runtime Environment (IcedTea 2.3.9) (Gentoo build 1.7.0_21-b02)OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Using the java command

Overview of the command

The java command can be run like so:

  • java [options] class [argument ...]
  • java [options] -jar file.jar [argument ...]

List of [options]

  • -client : Select the Java HotSpot Client VM. A 64-bit capable jdk currently ignores this option and instead uses the Java Hotspot Server VM.
  • -server : Select the Java HotSpot Server VM. On a 64-bit capable jdk only the Java Hotspot Server VM is supported so the -server option is implicit.
  • -agentlib:libname[=options] : Load a native agent library libname, e.g. -agentlib:hprof
  • -agentpath:pathname[=options] : Load a native agent library or full pathname.
  • -classpath : The path to the class.
  • -cp classpath : Specify a list of directories, JAR archives, and ZIP archives to search for class files. Class path entries are separated by colons (:). Specifying -classpath or -cp overrides any setting of the CLASSPATH environment variable. If -classpath and -cp are not used and CLASSPATH is not set, the user class path consists of the current directory.
  • -Dproperty=value : Set a system property value.
  • -d32 : Requests that the program be run in a 32-bit execution environment.
  • -d64 : Requests that the program be run in a 64-bit execution environment.
  • -enableassertions[:<package name>"..." | :<class name>]
  • -ea[:<package name>"..." | :<class name>] : With no arguments, -enableassertions or -ea enables assertions. With one argument ending in "...", the switch enables assertions in the specified package and any subpackages.
  • -disableassertions[:<package name>"..." | :<class name>]
  • -da[:<package name>"..." | :<class name>] : Disables assertions. This is the default. With no arguments, -disableassertions or -da disables assertions. With one argument ending in "...", the switch disables assertions in the specified package and any subpackages.
  • -esa : Enable asserts in all system classes (sets the default assertion status for system classes to true.)
  • -dsa : Disables asserts in all system classes.
  • -help : Display help info and exit
  • -jar : Execute a program encapsulated in a JAR file.
  • -javaagent:jarpath[=options] : Load a java programming language agent.
  • -jre-restrict-search : Include user-private JREs in the version search.
  • -no-jre-restrict-search : Exclude user-private JREs in the version search.
  • -splash:imagepath : Show splash screen with image specified by imagepath.
  • -verbose
  • -verbose:class : Display information on each class loaded.
  • -verbose:gc : Display information on each garbage collection event.
  • -verbose:jni : Display information on the use of native methods and other Java Native Interface activity.
  • -version : Display version information and exit.

Non-Standard [options]

  • -X : Display information about non-standard options and exit.
  • -Xint : Operate in interpreted-only mode. Compilation to native code is disabled, and all bytecodes are executed by the interpreter. The performance benefits offered by the Java HotSpot VMs' adaptive compiler will not be present in this mode.
  • -Xbatch : Disable background compilation.
  • -Xcheck:jni : Perform additional checks for Java Native Interface functions.
  • -Xfuture : Perform strict class-file format checks. Developers are encouraged to use this flag when developing new code because the stricter checks will become the default in future releases of the Java application handler.
  • -Xnoclassgc : Disable class garbage collection.
  • -Xincgc : Enable the incremental garbage collector. The incremental garbage collector, which is off by default, will reduce the occasional long garbage-collection pauses during execution.
  • -Xloggc:file : Report on each garbage collection event, as with -verbose:gc, but log this data to file.
  • -Xmsn : Specifiy the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB.
  • -Xmxn : Specify the maximum size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 2MB.
  • -Xprof : Profiles the running program, and sends profiling data to standard output.
  • -Xrs : Reduces the usage of operating-system signals by the Java virtual machine (Jvm).
  • -Xssn : Sets the thread stack size.
  • -XX:AllocationPrefetchStyle=n : Sets the style of prefetch used during allocation. Default=2.
  • -XX:+AggressiveOpts : Enables aggressive optimization.
  • -XX:+|-DisableAttachMechanism : This option specifies which tools are allowed to attach to the Jvm. By default, this feature is not enabled.
  • -XXLargePageSizeInBytes=n : Specifies the maximum size for large pages.
  • -MaxGCPauseMillis=n : Sets a target for the maximum garbage collection pause time.
  • -XX:ParallelGCThreads=n : Sets the number of GC threads in the parallel collectors.
  • -XX:+PrintCompilation : Prints verbose output from the HotSpot dynamic runtime compiler.
  • -XX:+PrintGCDetails -XX:+PrintGCTimeStamps : Prints garbage collection output along with time stamps.
  • -XX:SoftRefLRUPolicyMSPermMB=0 : This flag enables the aggressive processing of software references.
  • -XX:TLABSize=n


Everything from the "List of [options]" section was taken from the java man page. To look at this man page, type man java at the command line.