Java package: Difference between revisions

From Octave
Jump to navigation Jump to search
(remove the whole FAQ section which is part of the Octave manual)
m (Remove redundant Category:Packages.)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Java offers a rich, object oriented, and platform independent environment for many applications. The core Java classes can be easily extended by many freely available libraries. GNU Octave has a java interface that allows access to Java classes from inside Octave. Thus it is possible to use existing class files or complete Java libraries directly from Octave.


{{Warning|'''This package is not required for Octave versions 3.8.0 or later'''. Since Octave 3.8.0, Java support is part of Octave core.  Do not install this package as it will shadow core functions. However, even for those versions, Octave needs to have been built with java support (run {{codeline|octave_config_info ("JAVA")}}).  If it didn't, you'll have to rebuild Octave from source with that option.}}
= Octave 3.8 or later =


Octave is an easy to use but powerful environment for mathematical calculations, which can easily be extended by packages. Its features are close to the commercial tool MATLAB so that it can often be used as a replacement. Java on the other hand offers a rich, object oriented and platform independent  environment for many applications. The core Java classes can be easily extended by many freely available libraries. This document refers to the package <code>java</code>, which is part of the GNU Octave project. This package allows you to access Java classes from inside Octave. Thus it is possible to use existing class files or complete Java libraries directly from Octave.
{{Warning|Do not install the java package in Octave version 3.8.0 or later.}}


This description is based on the Octave package {{Codeline|java-1.2.8}}; however many items are equally valid for the built-in Java support in Octave-3.8.0 and higher.. The {{Forge|java}} package usually installs its script files (.m) in the directory {{Path|.../share/Octave/packages/java-1.2.8}} and its binary (.oct) files in {{Path|.../libexec/Octave/packages/java-1.2.8}}. You can get help on specific functions in Octave by executing the help command
GNU Octave 3.8.0 incorporated the Octave Forge java package so the package is no longer necessary. If the package is installed, it will shadow the core functions making the java interface unreliable.
with the name of a function from this package:
octave> help javaObject


You can view the whole doc file in Octave by executing the info command with just the word java:
However, even for these versions, Octave needs to have been built with java support. Check it like so:
octave> doc java


Note on calling Octave from Java: the java package is designed for calling Java from Octave. If you want to call Octave from Java, you might want to use a library like [http://kenai.com/projects/javaOctave javaOctave] or [http://jopas.sourceforge.net joPas].  
  >> (str2num(strtok(version(), '.')) > 4 && __octave_config_info__("JAVA")) || octave_config_info ("features").JAVA
  ans =  1


[[Category:Octave-Forge]]
If your installation of Octave does not have java support, it needs to be rebuilt from source.  See the pages specific to your Operating System for further details.
 
== Documentation ==
 
See the [http://www.gnu.org/software/octave/doc/interpreter/Java-Interface.html Java Interface] section of the Octave manual.
 
= Legacy versions -- Octave 3.6 and older =
 
Older versions of Octave did not have a native java interface.  Instead, the Octave Forge java package was required.  This needed to be installed separately via {{Codeline|pkg}}.  To install, download the [http://octave.sourceforge.net/java/index.html java package] and install it with {{Codeline|pkg install path-to-java.tar.gz}}
 
 
[[Category:Octave Forge]]

Latest revision as of 11:15, 10 June 2019

Java offers a rich, object oriented, and platform independent environment for many applications. The core Java classes can be easily extended by many freely available libraries. GNU Octave has a java interface that allows access to Java classes from inside Octave. Thus it is possible to use existing class files or complete Java libraries directly from Octave.

Octave 3.8 or later[edit]

Warning icon.svg
Do not install the java package in Octave version 3.8.0 or later.

GNU Octave 3.8.0 incorporated the Octave Forge java package so the package is no longer necessary. If the package is installed, it will shadow the core functions making the java interface unreliable.

However, even for these versions, Octave needs to have been built with java support. Check it like so:

 >> (str2num(strtok(version(), '.')) > 4 && __octave_config_info__("JAVA")) || octave_config_info ("features").JAVA
 ans =  1

If your installation of Octave does not have java support, it needs to be rebuilt from source. See the pages specific to your Operating System for further details.

Documentation[edit]

See the Java Interface section of the Octave manual.

Legacy versions -- Octave 3.6 and older[edit]

Older versions of Octave did not have a native java interface. Instead, the Octave Forge java package was required. This needed to be installed separately via pkg. To install, download the java package and install it with pkg install path-to-java.tar.gz