.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Java 3pm" .TH Java 3pm "2016-12-21" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Inline::Java \- Write Perl classes in Java. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use Inline Java => <<\*(AqEND_OF_JAVA_CODE\*(Aq ; \& class Pod_alu { \& public Pod_alu(){ \& } \& \& public int add(int i, int j){ \& return i + j ; \& } \& \& public int subtract(int i, int j){ \& return i \- j ; \& } \& } \& END_OF_JAVA_CODE \& \& my $alu = new Pod_alu() ; \& print($alu\->add(9, 16) . "\en") ; # prints 25 \& print($alu\->subtract(9, 16) . "\en") ; # prints \-7 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`Inline::Java\*(C'\fR module allows you to put Java source code directly \*(L"inline\*(R" in a Perl script or module. A Java compiler is launched and the Java code is compiled. Then Perl asks the Java classes what public methods have been defined. These classes and methods are available to the Perl program as if they had been written in Perl. .PP The process of interrogating the Java classes for public methods occurs the first time you run your Java code. The namespace is cached, and subsequent calls use the cached version. .SH "USING THE Inline::Java MODULE" .IX Header "USING THE Inline::Java MODULE" \&\f(CW\*(C`Inline::Java\*(C'\fR is driven by fundamentally the same idea as other \&\f(CW\*(C`Inline\*(C'\fR language modules, like \f(CW\*(C`Inline::C\*(C'\fR or \f(CW\*(C`Inline::CPP\*(C'\fR. Because Java is both compiled and interpreted, the method of getting your code is different, but overall, using \f(CW\*(C`Inline::Java\*(C'\fR is very similar to any other \f(CW\*(C`Inline\*(C'\fR language module. .PP This section will explain the different ways to \f(CW\*(C`use\*(C'\fR Inline::Java. For more details on \f(CW\*(C`Inline\*(C'\fR, see 'perldoc Inline'. .PP \&\fBBasic Usage\fR .PP The most basic form for using \f(CW\*(C`Inline::Java\*(C'\fR is: .PP .Vb 1 \& use Inline Java => \*(AqJava source code\*(Aq ; .Ve .PP Of course, you can use Perl's \*(L"here document\*(R" style of quoting to make the code slightly easier to read: .PP .Vb 1 \& use Inline Java => <<\*(AqEND\*(Aq; \& \& Java source code goes here. \& \& END .Ve .PP The source code can also be specified as a filename, a subroutine reference (the subroutine should return source code), or an array reference (the array contains lines of source code). This information is detailed in 'perldoc Inline'. .PP In order for \f(CW\*(C`Inline::Java\*(C'\fR to function properly, it needs to know where to find a Java 2 \s-1SDK\s0 on your machine. This is done using one of the following techniques: .IP "1." 4 Set the J2SDK configuration option to the correct directory .IP "2." 4 Set the \s-1PERL_INLINE_JAVA_J2SDK\s0 environment variable to the correct directory .PP If none of these are specified, \f(CW\*(C`Inline::Java\*(C'\fR will use the Java 2 \s-1SDK\s0 that was specified at install time (see below). .SH "DEFAULT JAVA 2 SDK" .IX Header "DEFAULT JAVA 2 SDK" When \f(CW\*(C`Inline::Java\*(C'\fR was installed, the path to the Java 2 \s-1SDK\s0 that was used was stored in a file called default_j2sdk.pl that resides within the \f(CW\*(C`Inline::Java\*(C'\fR module. You can obtain this path by using the following command: .PP .Vb 1 \& % perl \-MInline::Java=j2sdk .Ve .PP If you wish to permanently change the default Java 2 \s-1SDK\s0 that is used by \f(CW\*(C`Inline::Java\*(C'\fR, edit this file and change the value found there. If you wish use a different Java 2 \s-1SDK\s0 temporarily, see the J2SDK configuration option described below. .PP Additionally, you can use the following command to get the list of directories that you should put in you shared library path when using the \s-1JNI\s0 extension: .PP .Vb 1 \& % perl \-MInline::Java=so_dirs .Ve .SH "CONFIGURATION OPTIONS" .IX Header "CONFIGURATION OPTIONS" There are a number of configuration options that dictate the behavior of \f(CW\*(C`Inline::Java\*(C'\fR: .IP "j2sdk" 4 .IX Item "j2sdk" Specifies the path to your Java 2 \s-1SDK.\s0 .Sp .Vb 1 \& Ex: j2sdk => \*(Aq/my/java/2/sdk/path\*(Aq .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "port" 4 .IX Item "port" Specifies the port number for the server. Default is \-1 (next available port number), default for \s-1SHARED_JVM\s0 mode is 7891. .Sp .Vb 1 \& Ex: port => 4567 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "host" 4 .IX Item "host" Specifies the host on which the \s-1JVM\s0 server is running. This option really only makes sense in \s-1SHARED_JVM\s0 mode when \s-1START_JVM\s0 is disabled. .Sp .Vb 1 \& Ex: host => \*(Aqjvm.server.com\*(Aq .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "bind" 4 .IX Item "bind" Specifies the \s-1IP\s0 address on which the \s-1JVM\s0 server will be listening. By default the \s-1JVM\s0 server listens for connections on 'localhost' only. .Sp .Vb 2 \& Ex: bind => \*(Aq192.168.1.1\*(Aq \& Ex: bind => \*(Aq0.0.0.0\*(Aq .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "startup_delay" 4 .IX Item "startup_delay" Specifies the maximum number of seconds that the Perl script will try to connect to the Java server. In other words this is the delay that Perl gives to the Java server to start. Default is 15 seconds. .Sp .Vb 1 \& Ex: startup_delay => 20 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "classpath" 4 .IX Item "classpath" Adds the specified \s-1CLASSPATH.\s0 This \s-1CLASSPATH\s0 will only be available through the user classloader. To set the \s-1CLASSPATH\s0 globally (which is most probably what you want to do anyways), use the \s-1CLASSPATH\s0 environment variable. .Sp .Vb 1 \& Ex: classpath => \*(Aq/my/other/java/classses\*(Aq .Ve .IP "jni" 4 .IX Item "jni" Toggles the execution mode. The default is to use the client/server mode. To use the \s-1JNI\s0 extension (you must have built it at install time though; see \s-1README\s0 and \s-1README.JNI\s0 for more information), set \&\s-1JNI\s0 to 1. .Sp .Vb 1 \& Ex: jni => 1 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "extra_java_args, extra_javac_args" 4 .IX Item "extra_java_args, extra_javac_args" Specify extra command line parameters to be passed to, respectively, the \s-1JVM\s0 and the Java compiler. Use with caution as some options may alter normal \f(CW\*(C`Inline::Java\*(C'\fR behavior. .Sp .Vb 1 \& Ex: extra_java_args => \*(Aq\-Xmx96m\*(Aq .Ve .Sp Note: extra_java_args only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "embedded_jni" 4 .IX Item "embedded_jni" Same as jni, except \f(CW\*(C`Inline::Java\*(C'\fR expects the \s-1JVM\s0 to already be loaded and to have loaded the Perl interpreter that is running the script. This is an advanced feature that should only be need in very specific circumstances. .Sp .Vb 1 \& Ex: embedded_jni => 1 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 Also, the embedded_jni option automatically sets the \s-1JNI\s0 option. .IP "shared_jvm" 4 .IX Item "shared_jvm" This mode enables multiple processes to share the same \s-1JVM.\s0 It was created mainly in order to be able to use \f(CW\*(C`Inline::Java\*(C'\fR under mod_perl. .Sp .Vb 1 \& Ex: shared_jvm => 1 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "start_jvm" 4 .IX Item "start_jvm" When used with shared_jvm, tells \f(CW\*(C`Inline::Java\*(C'\fR whether to start a new \s-1JVM \s0(this is the default) or to expect that one is already running. This option is useful in combination with the command line interface described in the \s-1BUGS AND DEFICIENCIES\s0 section. Default is 1. .Sp .Vb 1 \& Ex: start_jvm => 0 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "private" 4 .IX Item "private" In shared_jvm mode, makes every connection to the \s-1JVM\s0 use a different classloader so that each connection is isolated from the others. .Sp .Vb 1 \& Ex: private => 1 .Ve .Sp Note: This configuration option only has an effect on the first \&'use Inline Java' call inside a Perl script, since all other calls make use of the same \s-1JVM.\s0 .IP "debug" 4 .IX Item "debug" Enables debugging info. Debugging now uses levels (1 through 5) that (loosely) follow these definitions: .Sp .Vb 5 \& 1 = Major program steps \& 2 = Object creation/destruction \& 3 = Method/member accesses + packet dumps \& 4 = Everything else \& 5 = Data structure dumps \& \& Ex: debug => 2 .Ve .IP "debugger" 4 .IX Item "debugger" Starts jdb (the Java debugger) instead of the regular Java \s-1JVM.\s0 This option will also cause the Java code to be compiled using the \&'\-g' switch for extra debugging information. \s-1EXTRA_JAVA_ARGS\s0 can be used use to pass extra options to the debugger. .Sp .Vb 1 \& Ex: debugger => 1 .Ve .IP "warn_method_select" 4 .IX Item "warn_method_select" Throws a warning when \f(CW\*(C`Inline::Java\*(C'\fR has to 'choose' between different method signatures. The warning states the possible choices and the signature chosen. .Sp .Vb 1 \& Ex: warn_method_select => 1 .Ve .IP "study" 4 .IX Item "study" Takes an array of Java classes that you wish to have \&\f(CW\*(C`Inline::Java\*(C'\fR learn about so that you can use them inside Perl. .Sp .Vb 1 \& Ex: study => [\*(Aqjava.lang.HashMap\*(Aq, \*(Aqmy.class\*(Aq] .Ve .IP "autostudy" 4 .IX Item "autostudy" Makes \f(CW\*(C`Inline::Java\*(C'\fR automatically study unknown classes when it encounters them. .Sp .Vb 1 \& Ex: autostudy => 1 .Ve .IP "package" 4 .IX Item "package" Forces \f(CW\*(C`Inline::Java\*(C'\fR to bind the Java code under the specified package instead of under the current (caller) package. .Sp .Vb 1 \& Ex: package => \*(Aqmain\*(Aq .Ve .IP "native_doubles" 4 .IX Item "native_doubles" Normally, \f(CW\*(C`Inline::Java\*(C'\fR stringifies floating point numbers when passing them between Perl and Java. In certain cases, this can lead to loss of precision. When native_doubles is set, \f(CW\*(C`Inline::Java\*(C'\fR will send the actual double bytes in order to preserve precision. Note: This applies only to doubles, not floats. Note: This option may not be portable and may not work properly on some platforms. .Sp .Vb 1 \& Ex: native_doubles => 1 .Ve .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" Every configuration option listed above, with the exception of \s-1STUDY,\s0 can be specified using an environment variable named using the following convention: .PP .Vb 1 \& PERL_INLINE_JAVA_