Java package: Difference between revisions

Jump to navigation Jump to search
15 bytes removed ,  30 November 2011
m
(porting java package documentaion)
 
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 = ’C:/Octave/java_files’;
  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, /someclasses.jar’]);
  octave> javaaddpath ([base_path, "/someclasses.jar"]);
  octave> javaaddpath([base_path, /moreclasses.jar’]);
  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, /someclasses.jar’]);
  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(~/octave’);
  addpath ("~/octave");
  javaaddpath(~/octave/myclasses.jar’);
  javaaddpath ("~/octave/myclasses.jar");


== How to create an instance of a Java class? ==
== How to create an instance of a Java class? ==

Navigation menu