/usr/share/doc/octave/octave.html/Making-Java-Classes-Available.html is in octave-doc 4.2.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Making Java Classes Available (GNU Octave)</title>
<meta name="description" content="Making Java Classes Available (GNU Octave)">
<meta name="keywords" content="Making Java Classes Available (GNU Octave)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Java-Interface.html#Java-Interface" rel="up" title="Java Interface">
<link href="How-to-use-Java-from-within-Octave.html#How-to-use-Java-from-within-Octave" rel="next" title="How to use Java from within Octave">
<link href="Java-Interface.html#Java-Interface" rel="prev" title="Java Interface">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<a name="Making-Java-Classes-Available"></a>
<div class="header">
<p>
Next: <a href="How-to-use-Java-from-within-Octave.html#How-to-use-Java-from-within-Octave" accesskey="n" rel="next">How to use Java from within Octave</a>, Up: <a href="Java-Interface.html#Java-Interface" accesskey="u" rel="up">Java Interface</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Making-Java-Classes-Available-1"></a>
<h4 class="subsection">A.4.1 Making Java Classes Available</h4>
<a name="index-classpath_002c-setting"></a>
<a name="index-classpath_002c-difference-between-static-and-dynamic"></a>
<a name="index-static-classpath"></a>
<a name="index-dynamic-classpath"></a>
<a name="index-javaclasspath_002etxt"></a>
<a name="index-classpath_002etxt"></a>
<a name="index-classes_002c-making-available-to-Octave"></a>
<p>Java finds classes by searching a <var>classpath</var> which is a list of Java
archive files and/or directories containing class files. In Octave the
<var>classpath</var> is composed of two parts:
</p>
<ul>
<li> the <var>static classpath</var> is initialized once at startup of the JVM, and
</li><li> the <var>dynamic classpath</var> which can be modified at runtime.
</li></ul>
<p>Octave searches the <var>static classpath</var> first, and then the
<var>dynamic classpath</var>. Classes appearing in the <var>static classpath</var>, as
well as in the <var>dynamic classpath</var>, will therefore be found in the
<var>static classpath</var> and loaded from this location. Classes which will be
used frequently, or must be available to all users, should be added to the
<var>static classpath</var>. The <var>static classpath</var> is populated once from the
contents of a plain text file named <samp>javaclasspath.txt</samp> (or
<samp>classpath.txt</samp> historically) when the Java Virtual Machine starts. This
file contains one line for each individual classpath to be added to the
<var>static classpath</var>. These lines can identify directories containing class
files, or Java archives with complete class file hierarchies. Comment lines
starting with a ‘<samp>#</samp>’ or a ‘<samp>%</samp>’ character are ignored.
</p>
<p>The search rules for the file <samp>javaclasspath.txt</samp> (or
<samp>classpath.txt</samp>) are:
</p>
<ul>
<li> First, Octave tries to locate it in the current directory (where Octave was
started from). If such a file is found, it is read and defines the initial
<var>static classpath</var>. Thus, it is possible to define a static classpath on a
’per Octave invocation’ basis.
</li><li> Next, Octave searches in the user’s home directory. If a file
<samp>javaclasspath.txt</samp> exists here, its contents are appended to the static
classpath (if any). Thus, it is possible to build an initial static classpath
on a ’per user’ basis.
</li><li> Finally, Octave looks for a <samp>javaclasspath.txt</samp> in the m-file directory
where Octave Java functions live. This is where the function
<samp>javaclasspath.m</samp> resides, usually something like
<samp><code><span class="nolinebreak">OCTAVE_HOME</span></code><!-- /@w -->/share/octave/<code><span class="nolinebreak">OCTAVE_VERSION</span></code><!-- /@w -->/m/java/</samp>.
You can find this directory by executing the command
<div class="example">
<pre class="example">which javaclasspath
</pre></div>
<p>If this file exists here, its contents are also appended to the
<var>static classpath</var>. Note that the archives and class directories defined
in this last step will affect all users.
</p></li></ul>
<p>Classes which are used only by a specific script should be placed in the
<var>dynamic classpath</var>. This portion of the classpath can be modified at
runtime using the <code>javaaddpath</code> and <code>javarmpath</code> functions.
</p>
<p>Example:
</p>
<div class="example">
<pre class="example">octave> base_path = "C:/Octave/java_files";
octave> # add two JAR archives to the dynamic classpath
octave> javaaddpath ([base_path, "/someclasses.jar"]);
octave> javaaddpath ([base_path, "/moreclasses.jar"]);
octave> # check the dynamic classpath
octave> p = javaclasspath;
octave> disp (p{1});
C:/Octave/java_files/someclasses.jar
octave> disp (p{2});
C:/Octave/java_files/moreclasses.jar
octave> # remove the first element from the classpath
octave> javarmpath ([base_path, "/someclasses.jar"]);
octave> p = javaclasspath;
octave> disp (p{1});
C:/Octave/java_files/moreclasses.jar
octave> # provoke an error
octave> disp (p{2});
error: A(I): Index exceeds matrix dimension.
</pre></div>
<p>Another way to add files to the <var>dynamic classpath</var> exclusively for your
user account is to use the file <samp>.octaverc</samp> which is stored in your home
directory. All Octave commands in this file are executed each time you start a
new instance of Octave. The following example adds the directory <samp>octave</samp>
to Octave’s search path and the archive <samp>myclasses.jar</samp> in this directory
to the Java search path.
</p>
<div class="example">
<pre class="example"># contents of .octaverc:
addpath ("~/octave");
javaaddpath ("~/octave/myclasses.jar");
</pre></div>
<hr>
<div class="header">
<p>
Next: <a href="How-to-use-Java-from-within-Octave.html#How-to-use-Java-from-within-Octave" accesskey="n" rel="next">How to use Java from within Octave</a>, Up: <a href="Java-Interface.html#Java-Interface" accesskey="u" rel="up">Java Interface</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|