659
edits
Carandraug (talk | contribs) (porting java package documentaion) |
Carandraug (talk | contribs) m (→How to make Java classes available to Octave?: fixing quotes) |
||
Line 31: | Line 31: | ||
Classes which are used only by a specific script should be placed in the dynamic ''classpath''. This portion of the ''classpath'' can be modified at runtime using the '''javaaddpath''' and '''javarmpath''' functions. Example: | Classes which are used only by a specific script should be placed in the dynamic ''classpath''. This portion of the ''classpath'' can be modified at runtime using the '''javaaddpath''' and '''javarmpath''' functions. Example: | ||
octave> base_path = | octave> base_path = "C:/Octave/java_files"; | ||
octave> % add two JARchives to the dynamic classpath | octave> % add two JARchives to the dynamic classpath | ||
octave> javaaddpath([base_path, | octave> javaaddpath ([base_path, "/someclasses.jar"]); | ||
octave> javaaddpath([base_path, | octave> javaaddpath ([base_path, "/moreclasses.jar"]); | ||
octave> % check the dynamic classpath | octave> % check the dynamic classpath | ||
octave> p = javaclasspath; | octave> p = javaclasspath; | ||
octave> disp(p{1}); | octave> disp (p{1}); | ||
C:/Octave/java_files/someclasses.jar | C:/Octave/java_files/someclasses.jar | ||
octave> disp(p{2}); | octave> disp (p{2}); | ||
C:/Octave/java_files/moreclasses.jar | C:/Octave/java_files/moreclasses.jar | ||
octave> % remove the first element from the classpath | octave> % remove the first element from the classpath | ||
octave> javarmpath([base_path, | octave> javarmpath ([base_path, "/someclasses.jar"]); | ||
octave> p = javaclasspath; | octave> p = javaclasspath; | ||
octave> disp(p{1}); | octave> disp (p{1}); | ||
C:/Octave/java_files/moreclasses.jar | C:/Octave/java_files/moreclasses.jar | ||
octave> % provoke an error | octave> % provoke an error | ||
octave> disp(p{2}); | octave> disp (p{2}); | ||
error: A(I): Index exceeds matrix dimension. | error: A(I): Index exceeds matrix dimension. | ||
Line 53: | Line 53: | ||
% content of .octaverc: | % content of .octaverc: | ||
addpath( | addpath ("~/octave"); | ||
javaaddpath( | javaaddpath ("~/octave/myclasses.jar"); | ||
== How to create an instance of a Java class? == | == How to create an instance of a Java class? == |