home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
readme.txt
< prev
next >
Wrap
Text File
|
1997-09-08
|
9KB
|
213 lines
========================
README for Win32 Samples
========================
This readme.txt file provides a brief description of the contents
of the subdirectories contained in this directory.
These subdirectories try to show different possible scenarios of
building Win32 native code from Java source code. They contain
tutorial type examples.
A makefile is provided in each subdirectory to build the example.
Some of the subdirectories contain Visual Cafe project(s) that
are already set up to build the example. We intentionally did
not supply project files for some of the examples because these
particular ones require additional command line tools to process.
The following lines briefly describe the build process of
each example.
simple
--------------
- Two java source files are compiled into an executable.
staticDLL
--------------
- Hello2.java is compiled into hello2.dll producing an
import library (hello2.lib) in the process.
- Main2.java is compiled and linked with hello2.lib to
produce staticDLL.exe.
- In order to run staticDLL.exe, the directory location of
hello2.dll should be in the PATH environment variable.
dynamicDLL
--------------
- Hello3.java is compiled into hello3.dll.
- Main3.java is compiled into dynamicDLL.exe.
- hello3.dll has to be registered in the Windows registry
file in order for the class Hello3 to be found when
dynamicDLL.exe is run. Refer to the Visual Cafe on-line
help on how to register a DLL using the snjreg tool.
resource
--------------
- The example in this directory shows how to bind resources into
an executable.
- Hello4.java contains class Hello4 that is a window application.
It uses Class.getResourceAsStream() method to query a property
list file named property.list. It will also load a GIF image
file symlogo.gif and display it on its window.
- hello4.res is a resource file generated using the snjres tool
from the file 'property.list' and the gif image file 'symlogo.gif'.
It can be generated using the following command line from the
resource\src directory:
snjres -f hello4.res samples\resource\property.list samples\resource\symlogo.gif
Note that in this example we have the package name directory
structure for the resource files.
- In the Visual Cafe project 'resource', take note that hello4.res is
included as a compiler flag option.
jni1
--------------
- The example in this directory shows how to compile a Java code
that contains a native method, into an executable.
- Hello5Impl.cpp is the C++ implementation of the native method.
- Hello5.java is compiled into a class file. The class file is needed
to create the C++ header file Hello5.h for Hello5Impl.cpp. In this
example, the header file is in jni format.
- Hello5Impl.cpp is compiled into hello5.dll producing the import
library hello5.lib as well.
- Hello5.java is then compiled and linked with hello5.lib to produce
an executable.
- Note that Microsoft's Visual C/C++ compiler will produce import
libraries in COFF format. The sj compiler will only recognize
OMF format import libraries. Use the COFF2OMF tool in the bin
directory to convert the import library into OMF format.
jni2
--------------
- The example in this directory shows how to invoke a Win32 native
implementation of the Java VM from within a C++ code.
- jni2.cpp contains code that calls JNI_CreateJavaVM() to create
a Java VM and it finds the Hello6 class and calls its static
method printHello(), all from the C++ code.
- Hello6.java is compiled into hello6.dll. hello6.dll needs
to be registered using the snjreg tool. Refer to the Visual
Cafe on-line help on how to register a DLL using the snjreg tool.
- jni2.cpp is compiled into jni2.exe.
- Note that the code in jni2.cpp as is will load the Java VM
dynamically during runtime. If static compilation with an
import library is desired, the macro STATIC has to be defined
and one can link the cpp file with the import library
snjjni.lib (if you are using Microsoft Visual C/C++ compiler)
or snjjni_omf.lib (if you are using Symantec C/C++ compiler).
rmi1
--------------
- The example in this directory shows how to compile Java codes that
use RMI.
- In this example, there is a Hello7Server.java file that contains
the class Hello7Server which implements a remote interface defined
in Hello7.java. The Hello7Client.java file contains the class
Hello7Client that uses RMI calls to two methods in class
Hello7Server.
- Use the makefile to build the two executables server1.exe and client1.exe.
It will also generate the skeleton and stub source files using the rmic
compiler. It will then compile the skeleton and stub files into a
DLL named hello7.dll.
- The user will have to register hello7.dll in the host where
the server program will run. Refer to the Visual Cafe on-line
help on how to register a DLL using the snjreg tool.
- Before running the server program, the RMI registry has to be created
first by running the rmiregistry tool. There is a Win32 native version
of the rmiregistry tool called snjrmiregistry.exe.
- If you will be running the client program on a different host, you
will need to register hello7.dll using the snjreg tool in the host
machine where the client program will run.
- Also, you will need to supply the host name or IP address of the RMI registry
host as a parameter in the command line, e.g. client <registry host-name>
rmi2
--------------
- The example in this directory is a slightly modified version of the
rmi1 example. Hello8Server.java contains code that will create the
RMI registry.
- The makefile will build two executables server2.exe and client2.exe.
- It will first compile Hello8Server.java into a class file. It then
uses that class file to generate the skeleton and the stub files
using the rmic compiler. In building server2.exe, it compiles
Hello8Server.java, Hello8.java, Hello8Server_Skel.java (the skeleton
file) and Hello8Server_Stub.java (the stub file) together into
the server executable. In building client2.exe, it compiles
Hello8.java, Hello8Client.java and Hello8Server_Stub.java into the
client executable.
- Note that since the RMI registry is created in the Hello8Server.java
code, this has different implications over the previous rmi1 example.
conversion
--------------
- There are five subdirectories contained in this directory. The
example in this directory tries to show steps in converting a
Java applet into a Win32 native application. It also shows
two ways of including components into a Win32 native application
project. Each of the subdirectories contains a Visual Cafe
project showing a step in the conversion process.
- step1 contains a project for a Java applet.
- step2 modifies the step1 project into a Java application. The
file MainFrame.java is added to serve the main entry class for
the application and as a placeholder for the applet.
- step3 tries to modify the step2 project for a Win32 application
by just changing the project options. This project will not
build. Linker errors like the following ones will show up ...
Error: out\samples\conversion\Applet1.obj(Applet1) (65535):
Symbol Undefined _$Classsamples_conversion_ScrollingText
Error: out\samples\conversion\Applet1.obj(Applet1) (65535):
Symbol Undefined _$samples_conversion_ScrollingText__4init_5__Ljava_lang_String_2II
The java file ScrollingText.java is not included in the project and
this will cause a linker error while it will not cause any errors
in building the previous bytecode projects step1 and step2.
- step4 added the file ScrollingText.java into the project. The
project will now build successfully.
- step5 adds a new component called JmScale to the project by
creating another project and adding the JmScale project as
a subproject. The JmScale project is setup to build a DLL
from the JmScale component. Applet1.java in the main project
is modified to contain the new component.
- Makefiles are provided as well, and they simulate the project files
in building this example. Note that you will also get linker errors
if you use the makefile in step3 to build.