HP-UX Programmer's Guide for Java 2
Table Of Contents
- Table of Contents
- 1 Introduction
- 2 HotSpot Technology Tools and Commands
- 3 Configuration for Java™ Support
- 4 Performance and Tuning
- 5 Measuring System Performance
- 6 Using Threads
- 7 Using Signals
- 8 Using Java™ 2 JNI on HP-UX
- 9 Expanding Memory
- Determine your requirements
- Memory layout under HP-UX 11.0 (PA-RISC only)
- Additional memory available under HP-UX 11i (PA-RISC only)
- Allocating physical memory and swap in the Java™ heap
- Useful key command-line options for allocating memory
- Application-dependent considerations using large heap size HP-UX 11i PA-RISC
- Expanding heap size in native applications on PA-RISC HP-UX 11.11 and later releases
- Expanding heap size in native applications on Integrity HP-UX 11.23 and later releases
- Expanding heap size in HP-UX PA-RISC
- Expanding heap size in HP-UX Integrity
- 10 Diagnosing Memory Leaks
- A JDK/JRE 6.0.n and 7.0.n Usage Notes
- Using Java 2 JNI on HP-UX
- Garbage collection
- Asian TrueType fonts and Asian locales
- Date/Time methods defaults
- Profiling
- Compatibility with previous releases
- Java Cryptography Extension (JCE) policy files
- Configuring the Java Runtime Plug-In
- CLASSPATH environment variable
- Java Web Start technology usage
- Upgrading from a previous Java Web Start version
- IPv6 support
- Allocation Site Statistics and Zero Preparation -Xverbosegc
- JDK 6.0.04 flags
- GC log-rotation support
- NUMA collector enhancements
- ThreadDumpPath support
- Garbage-First garbage collector (-XX:+UseG1GC)
- jmap, jinfo, and jstack tools included in JDK 6.0.03
- Additional Java Web Start documentation
- B JDK/JRE 5.0.n Usage Notes
- Using Java 2 JNI on HP-UX
- Garbage collectors: Parallel and Concurrent Mark Sweep
- Allocating physical memory and swap in the Java heap
- Asian TrueType fonts and Asian locales
- Date/Time methods defaults
- Profiling
- Closing a socket (PA-RISC only)
- Compatibility with previous releases
- Java Cryptography Extension (JCE) policy files
- Allocation Site Statistics and Zero Preparation -Xverbosegc
- IPv6 support on Java 5.0
- GC log-rotation support in 5.0
- ThreadDumpPath support in 5.0
- Dynamically loaded libraries in 5.0
- Performance improvement for String.intern()
- Configuring the Java Runtime Plug-In
- CLASSPATH environment variable
- Java Web Start technology usage
- C SDK/RTE 1.4.2.n Usage Notes
- Removing support for unwanted architectures in the JRE
- Support for dynamic thread local storage (TLS)
- Signal Chaining functionality
- Using Java 2 JNI on HP-UX
- HotSpot JVM options
- Garbage collectors: Parallel and Concurrent mark sweep
- Allocating physical memory and swap in the Java heap
- Asian TrueType fonts and Asian locales
- Date/Time methods defaults
- Profiling
- Closing a socket when accept or read is pending (PA-RISC) - new patch information!
- Compatibility with previous releases
- Runtime Plug-In usage and configuration
- GC log-rotation support
- ThreadDumpPath support
- D Additional Resources
- Index

NOTE: You are required to supply either -Aa or -Ae as a command-line option to
the C compiler. The Java™ header files that you must include require support for ANSI
C prototypes.
Create the shared library containing the native method implementation:
PA-RISC:
$ aCC -b -o libaCCImpl.sl aCCImpl.o \
-lstd -lstream -lCsup -lm
(see below for Integrity)
Output:
libcImpl.sl
Use libcImpl.so on Integrity
To execute the Java™ program, you must set the SHLIB_PATH environment variable
to contain the location of the directory that contains libcImpl.sl (libcImpl.so on
IPF). SHLIB_PATH is the HP-UX name for LD_LIBRARY_PATH and can contain a list
of directories each separated by colons.
$ export SHLIB_PATH=.:$SHLIB_PATH
$ <java_dir>/bin/java TestJava2CallingNative cImpl
Library cImpl successfully loaded
Calling sayHelloWorld
C says HelloWorld via stdio
All done
Sample Java™ calling native method implementation in HP aC++
Here is a sample Java™ program that calls a native method which has a C++
implementation. This C++ example will use the aC++ compiler. HP has two different
C++ compilers, an older cfront-based product and a newer aC++ compiler. You can tell
which C++ compiler you are using by the name of the driver. The older cfront based
product uses CC as the driver, while the newer aC++ compiler uses aCC as the name
of the driver. The official HP product names for these two C++ compilers are HP C++
for the cfront-based product and HP aC++ for the new C++ compiler.
NOTE: In the HP-UX SDK, for the Java™ 2 Platform there is support for the HP aC++
compiler, but not for the older cfront HP C++ compiler. Since the HP-UX SDK, for the
Java™ 2 Platform contains C++ libraries built with the HP aC++ compiler, any user
shared libraries compiled with cfront are not compatible. Therefore, you have to
recompile your shared libraries with HP aC++ if you intend to use them with the HP-UX
SDK for the Java™ 2 Platform.
//
// TestJava2CallingNative.java
//
class TestJava2CallingNative {
Java™ calling a native (non-Java) method 49