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