ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/othlang.htm

137 lines
8.7 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Java with other programming languages" />
<meta name="abstract" content="With Java, you have multiple ways to call code that was written in languages other than Java." />
<meta name="description" content="With Java, you have multiple ways to call code that was written in languages other than Java." />
<meta name="DC.Relation" scheme="URI" content="whatitis.htm" />
<meta name="DC.Relation" scheme="URI" content="jni.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahapaseexmplsmain.htm" />
<meta name="DC.Relation" scheme="URI" content="rzahateraspacemain.htm" />
<meta name="DC.Relation" scheme="URI" content="ilejava.htm" />
<meta name="DC.Relation" scheme="URI" content="javalang.htm" />
<meta name="DC.Relation" scheme="URI" content="interpro.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="othlang" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Java with other programming languages</title>
</head>
<body id="othlang"><a name="othlang"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Java with other programming languages</h1>
<div><p>With Java™, you have multiple ways to call code that was written
in languages other than Java.</p>
<p><strong>Java Native
Interface</strong></p>
<p>One of the ways you can call code written in another language is to implement
selected Java methods as 'native methods.' Native methods are
procedures, written in another language, that provide the actual implementation
of a Java method.
Native methods can access the Java virtual machine using the Java Native
Interface (JNI). These native methods run under the Java thread,
which is a kernel thread, so they must be thread safe. A function is thread
safe if you can start it simultaneously in multiple threads within the same
process. A function is thread safe if and only if all the functions it calls
are also thread safe.</p>
<p>Native methods are a "bridge" to access system functions that are not directly
supported in Java, or to interface to existing user code. Use caution
when using native methods, because the code that is being called may not be
thread safe. ee <a href="jni.htm">Use the Java Native Interface for native methods</a> for
more information about JNI and ILE native methods.</p>
<p><strong>Java Invocation
API</strong></p>
<p>Using the <a href="invocapi.htm">Java Invocation API</a>, which is also
a part of the Java Native Interface (JNI) specification, allows a
non-Java application to use the Java virtual machine. It also allows the
use of Java code as an extension of the application.</p>
<p><strong><span class="keyword">i5/OS™</span> PASE native
methods</strong></p>
<p>The iSeries™ Java virtual
machine (JVM) now supports the use of native methods running in the <span class="keyword">i5/OS</span> PASE environment. <a href="rzahapaseexmplsmain.htm"><span class="keyword">i5/OS</span> PASE native methods for Java</a> enables
you to easily port your Java applications that run in AIX<sup>®</sup> to your iSeries server.
You can copy the class files and AIX native method libraries to the integrated
file system on the iSeries nd run them from any of the control language
(CL), Qshell or <span class="keyword">i5/OS</span> PASE
terminal session command prompts.</p>
<p><strong>Teraspace native methods</strong></p>
<p>The iSeries Java virtual
machine (JVM) now supports the use of teraspace storage model native methods.
The teraspace storage model provides a large process, local-address environment
for ILE programs. Using teraspace allows you to port native method code from
other operating systems to <span class="keyword">i5/OS</span> with
little or no changes to your source code.</p>
<p><strong>java.lang.Runtime.exec()</strong></p>
<p>You can use <a href="javalang.htm">java.lang.Runtime.exec()</a> to
call programs or commands from within a Java program. The exec() method starts another
process in which any iSeries program or command can run. In this model,
you can use standard in, standard out, and standard err of the child process
for interprocess communication.</p>
<p><strong>Interprocess communication</strong></p>
<p>One option is to use <a href="sockets.htm">sockets</a> for interprocess
communication between the parent and child processes.</p>
<p>You can also use <a href="iostream.htm">stream files</a> for communication
between programs. Or see <a href="interpro.htm">interprocess communication
examples</a> for an overview of your options when communicating with programs
that are running in another process.</p>
<p>To call Java from other languages, see <a href="callcex.htm">Example:
Call Java from
C</a> or <a href="calrpgex.htm">Example: Call Java from
RPG</a> for more information.</p>
<p>You can also use the <a href="../rzahh/page1.htm" target="_blank">IBM<sup>®</sup> Toolbox
for Java</a> to
call existing programs and commands on the iSeries server. Data queues and iSeries messages
are usually used for interprocess communication with the IBM Toolbox for Java.</p>
<div class="note"><span class="notetitle">Note:</span> By using Runtime.exec(), IBM Toolbox for Java, or JNI, you may compromise the portability
of the Java program. You should avoid using these methods in
a "pure" Java environment.</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="jni.htm">Use the Java Native Interface for native methods</a></strong><br />
You should only use native methods in cases where pure Java cannot
meet your programming needs.</li>
<li class="ulchildlink"><strong><a href="rzahapaseexmplsmain.htm">IBM i5/OS PASE native methods for Java</a></strong><br />
The iSeries Java virtual
machine (JVM) supports the use of native methods running in the <span class="keyword">i5/OS</span> PASE
environment. Prior to V5R2, the native iSeries JVM used only ILE native methods.</li>
<li class="ulchildlink"><strong><a href="rzahateraspacemain.htm">Teraspace storage model native methods for Java</a></strong><br />
The iSeries Java virtual
machine (JVM) now supports the use of teraspace storage model native methods.
The teraspace storage model provides a large process-local address environment
for ILE programs. Using teraspace allows you to port native method code from
other operating systems to <span class="keyword">i5/OS</span> with
little or no source code changes.</li>
<li class="ulchildlink"><strong><a href="ilejava.htm">Comparison of Integrated Language Environment and Java</a></strong><br />
The Java environment on an iSeries server is separate from the integrated
language environment (ILE). Java is not an ILE language, and it cannot
bind to ILE object modules to create programs or service programs on an iSeries server.</li>
<li class="ulchildlink"><strong><a href="javalang.htm">Use java.lang.Runtime.exec()</a></strong><br />
Use the java.lang.Runtime.exec method to call programs or commands
from within your Java program. Using java.lang.Runtime.exec() method
creates one or more additional thread-enabled jobs. The additional jobs process
the command string that you pass on the method.</li>
<li class="ulchildlink"><strong><a href="interpro.htm">Interprocess communications</a></strong><br />
When communicating with programs that are running in another process, there are a number of options.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="whatitis.htm" title="Java compatibleIBM Developer Kit for Java is optimized for use in an iSeries server environment. It uses the compatibility of Java programming and user interfaces, so you can develop your own applications for the iSeries server.">IBM Developer Kit for Java</a></div>
</div>
</div>
</body>
</html>