[58cba7f0] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ojdk-conf" xreflabel="Configuring the JAVA environment">
|
---|
| 9 | <?dbhtml filename="ojdk-conf.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>Configuring the JAVA environment</title>
|
---|
| 17 |
|
---|
[55bcdd7] | 18 | <sect2 id="java-profile">
|
---|
| 19 | <title>Setting up the environment</title>
|
---|
| 20 |
|
---|
[58cba7f0] | 21 | <para>
|
---|
| 22 | After the package installation is complete, the next step is to make sure
|
---|
| 23 | that the system can properly find the files. If you set up your login
|
---|
| 24 | scripts as recommended in <xref linkend='postlfs-config-profile'/>, update
|
---|
| 25 | the environment by creating the <filename>openjdk.sh</filename> script,
|
---|
| 26 | as the <systemitem class="username">root</systemitem> user:
|
---|
| 27 | </para>
|
---|
| 28 |
|
---|
| 29 | <screen role="root"><userinput>cat > /etc/profile.d/openjdk.sh << "EOF"
|
---|
| 30 | <literal># Begin /etc/profile.d/openjdk.sh
|
---|
| 31 |
|
---|
| 32 | # Set JAVA_HOME directory
|
---|
| 33 | JAVA_HOME=/opt/jdk
|
---|
| 34 |
|
---|
| 35 | # Adjust PATH
|
---|
| 36 | pathappend $JAVA_HOME/bin
|
---|
| 37 |
|
---|
| 38 | # Add to MANPATH
|
---|
| 39 | pathappend $JAVA_HOME/man MANPATH
|
---|
| 40 |
|
---|
| 41 | # Auto Java CLASSPATH: Copy jar files to, or create symlinks in, the
|
---|
| 42 | # /usr/share/java directory. Note that having gcj jars with OpenJDK 8
|
---|
| 43 | # may lead to errors.
|
---|
| 44 |
|
---|
| 45 | AUTO_CLASSPATH_DIR=/usr/share/java
|
---|
| 46 |
|
---|
| 47 | pathprepend . CLASSPATH
|
---|
| 48 |
|
---|
| 49 | for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
|
---|
| 50 | pathappend $dir CLASSPATH
|
---|
| 51 | done
|
---|
| 52 |
|
---|
| 53 | for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
|
---|
| 54 | pathappend $jar CLASSPATH
|
---|
| 55 | done
|
---|
| 56 |
|
---|
| 57 | export JAVA_HOME
|
---|
| 58 | unset AUTO_CLASSPATH_DIR dir jar
|
---|
| 59 |
|
---|
| 60 | # End /etc/profile.d/openjdk.sh</literal>
|
---|
[77b64bd] | 61 | EOF</userinput></screen>
|
---|
| 62 |
|
---|
| 63 | <para>
|
---|
| 64 | If <xref linkend="sudo"/> is installed, the super user should have
|
---|
| 65 | access to the above variables. Execute the following commands as the
|
---|
| 66 | <systemitem class="username">root</systemitem> user:
|
---|
| 67 | </para>
|
---|
| 68 |
|
---|
| 69 | <screen role="root"><userinput>cat > /etc/sudoers.d/java << "EOF"
|
---|
| 70 | <literal>Defaults env_keep += JAVA_HOME
|
---|
| 71 | Defaults env_keep += CLASSPATH</literal>
|
---|
[58cba7f0] | 72 | EOF</userinput></screen>
|
---|
| 73 |
|
---|
| 74 | <para>
|
---|
| 75 | For allowing <command>mandb</command> to include the OpenJDK man pages
|
---|
| 76 | in its database, issue, as the <systemitem class="username">root
|
---|
| 77 | </systemitem> user:
|
---|
| 78 | </para>
|
---|
| 79 |
|
---|
| 80 | <screen role="root"><userinput>cat >> /etc/man_db.conf << "EOF" &&
|
---|
| 81 | <literal># Begin Java addition
|
---|
| 82 | MANDATORY_MANPATH /opt/jdk/man
|
---|
| 83 | MANPATH_MAP /opt/jdk/bin /opt/jdk/man
|
---|
| 84 | MANDB_MAP /opt/jdk/man /var/cache/man/jdk
|
---|
| 85 | # End Java addition</literal>
|
---|
| 86 | EOF
|
---|
| 87 |
|
---|
[f9f0406c] | 88 | mkdir -p /var/cache/man &&
|
---|
[58cba7f0] | 89 | mandb -c /opt/jdk/man</userinput></screen>
|
---|
| 90 |
|
---|
[55bcdd7] | 91 | </sect2>
|
---|
| 92 |
|
---|
| 93 | <sect2 id="ojdk-certs" xreflabel="installing the JVM Certificate Authority Certificates">
|
---|
| 94 |
|
---|
| 95 | <title>Setting up the Certificate Authority Certificates for Java</title>
|
---|
| 96 |
|
---|
| 97 | <para>
|
---|
| 98 | <application>OpenJDK</application> uses its own format for the
|
---|
| 99 | CA certificates. The Java security modules use
|
---|
| 100 | <envar>$JAVA_HOME</envar><filename>/lib/security/cacerts</filename> by
|
---|
| 101 | default. In order to keep all the certificates in one place, we use
|
---|
[8944fff] | 102 | <filename>/etc/ssl/java/cacerts</filename>. The instructions
|
---|
| 103 | on the <xref linkend="make-ca"/> page previously created the file
|
---|
[55bcdd7] | 104 | located in <filename class="directory">/etc/ssl/java</filename>.
|
---|
[8944fff] | 105 | Setup a symlink in the default location as the
|
---|
[55bcdd7] | 106 | <systemitem class="username">root</systemitem> user:
|
---|
| 107 | </para>
|
---|
| 108 |
|
---|
[8944fff] | 109 | <screen role="root"><userinput>ln -sfv /etc/pki/tls/java/cacerts /opt/jdk/lib/security/cacerts</userinput></screen>
|
---|
[55bcdd7] | 110 |
|
---|
[58cba7f0] | 111 | <para>
|
---|
[8944fff] | 112 | Use the following command to check if the <filename>cacerts</filename>
|
---|
[55bcdd7] | 113 | file has been successfully installed:
|
---|
[58cba7f0] | 114 | </para>
|
---|
| 115 |
|
---|
[8944fff] | 116 | <screen role="root"><userinput>/opt/jdk/bin/keytool -list -cacerts</userinput></screen>
|
---|
[55bcdd7] | 117 |
|
---|
| 118 | <para>
|
---|
| 119 | At the prompt <computeroutput>Enter keystore password:</computeroutput>,
|
---|
| 120 | enter <userinput>changeit</userinput> (the default) or just press the
|
---|
| 121 | <quote>Enter</quote> key. If the <filename>cacerts</filename> file was
|
---|
| 122 | installed correctly, you will see a list of the certificates with
|
---|
| 123 | related information for each one. If not, you need to reinstall them.
|
---|
| 124 | </para>
|
---|
| 125 |
|
---|
| 126 | <para>
|
---|
| 127 | If you later install a new JVM, you just have to create the symlink in
|
---|
| 128 | the default location to be able to use the cacerts.
|
---|
| 129 | </para>
|
---|
| 130 |
|
---|
| 131 | </sect2>
|
---|
| 132 |
|
---|
[58cba7f0] | 133 | </sect1>
|
---|