Java Reference
In-Depth Information
the source code directory. The -d switch on the javac command line does just
that. The compiler also needs to know where to look for already compiled class
files that might be needed as new files are compiled. The familiar -classpath
switch handles that and should point to the same directory as the -d output
directory. First, we create the build and build/classes directories. For
aWindows bat script, the mkdir command must use the standard Windows
“\ character as a directory separator. Elsewhere we use the conventional /
between directory names since the javac tool knows how to interpret it.
rem Create the build and class directories
mkdir build
mkdir build \ classes
Next we set up some environment variables to make the compilation lines a little
shorter:
rem setup some environment variables to use as abbreviations
set classdir = build/classes
set cp = %classdir%
set ifcdir = src/javatech/rmi18/server
set impldir = src/javatech/rmi18/server/impl
set clientdir = src/javatech/rmi18/client
And finally we compile all the sources:
rem Compile everything
javac -classpath% cp% -d %classdir% %ifcdir%/*.java
javac -classpath% cp% -d %classdir% %impldir%/*.java
javac -classpath% cp% -d %classdir% %clientdir%/*.java
18.6.2 Run the rmic compiler
The next step is to generate the stubs and skeletons using the rmic compiler.
It operates on the remote implementation class file, not the source file, so the
javac compilation must be completed first. The input to rmic must be the fully
qualified implementation class - i.e. with the complete package name prefix,
javatech.rmi18.server.impl.RMIExample .Ofcourse rmic needs to
know the local CLASSPATH so it will know where to begin looking for the
named class to compile. We also want to direct the rmic output to the same
build/classes tree used for other class files. Just like javac , rmic uses
the -d switch to indicate the output directory. Continuing with the Windows bat
script begun above, we run rmic as follows (line split to fit page):
rmic -classpath %cp% -d %classdir%
javatech.rmi18.server.impl.RMIExampleImpl
Search WWH ::




Custom Search