NetWare has had a reputation for being a great file and print server, but it’s not often considered for running applications. One of the main reasons for this was the fact that NetWare Loadable Modules (NLMs) are very difficult to create and debug. You can avoid the problem of writing NLMs, though, by running Java applications on your NetWare servers instead. In this Daily Drill Down, I’ll show you what’s involved in running Java on your NetWare servers.
How Java works on NetWare
Java works the same way on NetWare as it does on other platforms. Java applications run on a Java Virtual Machine (JVM), which translates the Java code into code that the platform hosting the JVM can understand. In the case of NetWare, the JVM is actually made up of a set of NLMs. You don’t need to worry about writing NLM code or dealing with the NLMs, though. All you have to do is write Java code, and you’re ready to go.
Novell claims that code that meets JavaSoft’s 100% PureJava standard will run without modification. Programs that don’t meet this standard must be modified to run on NetWare. Of course, if you’ve ever worked with Java before, you know that almost nothing runs in a JVM on the first try. That’s usually due to subtle incompatibilities in the different JVMs.
Along with the NLMs that make up the JVM, NetWare includes Symantec’s Just In Time (JIT) compiler. The JIT compiles Java code on the fly directly into NetWare code. Without a compiler, the JVM has to interpret and convert each line as it goes. This, as you can guess, would make Java applications very slow.
Java applications have a reputation for general sluggishness when compared to native applications, due primarily to the need to interpret the code or compile it on the fly. Java applications are also generally slower than NetWare NLMs because Novell has designed the JVM to run in protected mode. Protected mode prevents the JVM from crashing the entire server should something go wrong with the Java application.
NLMs run in Ring 0, the lowest and fastest CPU level. However, applications running at Ring 0 can easily crash a server if they’re not designed precisely. This is one of the reasons programmers don’t go into programming NLMs very much. They are very difficult to code and very unforgiving if something went wrong. On the flip side, they’re very fast—far faster than Java applications.
Any server that meets NetWare 5.1’s minimum system requirements can run Java applications. Novell recommends that you have at least 32 MB of main memory to run text-based Java applications and at least 64 MB to run graphical applications. This memory requirement is above the needs of the base operating system. So, if you’re in a situation where your server is using all of its resources just to boot the OS and mount volumes, you’ll need to add memory. Novell subscribes to the “more is better” theory of RAM management by noting that the more memory a server has, the more Java applications it can run.
For Java applications that require a GUI, NetWare includes XFree86 as its default X Windows server. XFree86 is a very popular standard with versions that run on platforms as diverse as OS/2 and Linux. NetWare’s Xfree86 supports video cards that are compliant with VESA versions 1.2 through 3.0.
The main limitation to NetWare’s version of Xfree86 is that it only supports 256 colors. Even if you install the latest GeForce 3D card capable of full 32-bit color, NetWare will only display 256 colors. NetWare’s also limited to a display resolution of 1024×768. As long as you have a VESA-compliant card in your server, NetWare will default to a screen resolution of 640×480 with 256 colors. If it can’t launch that mode, it will default to plain VGA with a resolution of 640×480 with 16 colors.
Running Java applications
Unless you’ve modified your server’s AUTOEXEC.NCF file, when your server starts its servertop GUI (as a part of the STARTX.NCF file), Java loads automatically. If the GUI isn’t currently loaded on your server, you can check to see if Java’s loaded by going to the server’s console prompt, typing modules java, and pressing [Enter]. If Java’s already running on your server, you’ll see the current version of Java loaded on your server. If you just see another server prompt, with no information about your Java version, Java isn’t loaded on your server.
If Java isn’t running on your server, you can start it by typing load java and pressing [Enter] at the server’s console prompt. This will start Java and return you to the server’s console prompt. If you want to start Java and load NetWare’s GUI at the same time, type load startx at the server’s console prompt and press [Enter]. You can unload Java two ways: Type unload java at the server’s console prompt and press [Enter], or type java –exit at the server’s console prompt and press [Enter].
After you’ve loaded Java, you can then run Java applications or applets on your server. Applets are small programs that run inside larger applications and require a different command to load than Java applications. To start a Java program (either applet or application) you must first copy the application or applet files to the SYS:\Java\classes directory.
You can also copy the files to another directory, but if you do, it makes things a little more complicated. If you copy application files to a directory other than the default, you must add the location of the files to the CLASSPATH environment variable so the JVM can find the files. If you want to place applets in a directory other than SYS:\Java\classes, you must specify the path for the applet when you go to execute it from the command line. Applet pathnames aren’t affected by the CLASSPATH. I’ll discuss how to modify Java environment variables in just a bit.
To start a Java application, go to the server’s console prompt and type java classname, where classname is the file name of the Java application. You don’t need to specify a path name. NetWare will load the application, along with its GUI if the application is graphical.
If the application is text-based and requires user input, you must start the Java application by typing java -ns classname. The -ns switch causes NetWare to launch a separate screen for the Java application.
By default, Java applications take 32 MB of virtual memory. If you want to start the application with a different amount of RAM, you can do so by using the -vm switch. Type java -vmbytes classname at the server’s console prompt, where bytes is the number of megabytes of RAM you want to reserve and classname is the name of the application you want to run, and press [Enter].
To run a Java applet, type applet appletname, where appletname represents the filename for the applet if it’s located in the SYS:\Java\classes directory or the applet’s full pathname if the file is located in another directory. When you start an applet, NetWare’s JVM automatically loads the NetWare GUI. Applets are always displayed in an applet viewer in the servertop.
To see what Java programs are running on your server, go to the server’s console prompt, type java –show, and press [Enter]. You’ll see a list of currently running Java applications and applets, along with an ID for each application. You can use the ID value to end a Java application or applet from the server console. To do so, type java –killID, where you replace ID with the ID number you found from the java –show command.
Modifying Java environment variables
As I mentioned, if you want to locate a Java application in a directory other than the default directory of SYS:\Java\classes, you must modify the CLASSPATH environment variable. You should be aware of several environment variables, including:
- · CLASSPATH
- · CWD
- · DEBUGGER
- · DISPLAY
- · JAVA_COMPILER
- · JAVA_HOME
- · OSA_HOME
- · XLOCALEDIR
You can view all of the current environment settings by typing envset at the server’s console prompt and pressing [Enter]. Don’t be surprised if you see your server’s screen quickly fill up and scroll off the top. Environment variables can be complex and, shown together, they can often more than fill one screen. You can view environment variables one at a time by typing envset variable, where variable is the name of the individual variable you want to view.
The basic syntax for setting an environment variable is envset variable=value;value. However, each environment variable has subtle differences, so make sure you understand what each variable does and its various settings before using the envset command.
The CLASSPATH variable tells NetWare’s JVM where to look for Java applications. The default value for CLASSPATH is SYS:\Java\classes. You can substitute a new CLASSPATH by typing envset classpath=volume:directory, where volume is the volume and directory is the directory where the applications are stored.
Using this command replaces the previously specified CLASSPATH with your new one. If you want to include your new path with the old one, type envset classpath=$classpath;volume:directory. The $classpath switch tells NetWare’s JVM to use your new path, as well as the old ones. Make sure there are no spaces on either side of the equal sign or between values. Remember that if you have multiple values, you must separate them with semicolons.
Be careful when modifying the CLASSPATH variable. If the CLASSPATH variable is set incorrectly, your Java applications won’t run. If you run the envset classpath command by itself, you may be surprised by the number of lines that CLASSPATH takes up. You can improve performance of your Java applications by reducing the size of the CLASSPATH variable. Just eliminate unused directories from your envset classpath= command.
The Current Working Directory (CWD) environment variable can be used to run an application in a specific directory outside of the ones specified in the CLASSPATH directory. The CWD variable is set to the root of your server’s SYS volume by default. To change CWD, type envset cwd=volume:directory. Novell recommends that if you must change the current working directory, you do so by specifying it when loading Java rather than by using the envset command. Novell’s recommended command is java -envcwd=volume:directory appname, where appname is the application you want to run.
The DEBUGGER environment variable tells NetWare what debugger to use if a problem occurs in a Java application. You probably won’t have to worry about this variable unless you’re developing Java applications rather than just running them. You can’t change this variable from the server’s console prompt. You can only change it by editing the JAVA.CFG file before starting Java on your server. In the JAVA.CFG file, type DEBUGGER=debugger. You’ll replace debugger with SUN if you’re using Sun’s JDB debugger or a debugger that uses JDB, such as Visual Age. Alternatively, you can replace debugger with SYMC if you’re using the Symantec Visual Cafe.
The DISPLAY environment variable controls how the NetWare GUI appears on the screen. As you can see, its default value is a localhost TCP/IP address of 127.0.0.1. Don’t change this. If you do, you may not be able to view the GUI on your server’s monitor any more. Only change this variable if you’ve used X Windows in a UNIX environment before and are completely comfortable with it.
The JAVA_COMPILER environment variable allows you to enable and disable the JIT compiler for NetWare. By default, the JIT loads when Java loads. Because the JIT increases Java performance, you should only disable it if an application doesn’t work with the JIT. To disable the JIT for all Java applications, type envset java_compiler= making sure not to enter anything after the equals sign. To reenable the JIT, type envset java_compiler=symcjit. If you just want to disable the JIT for a single Java application, you can do so by typing java –nojitapplication, where application is the name of the application you want to run.
The JAVA_HOME environment variable specifies the location of the JVM. The default location of the Novell JVM for NetWare is SYS:\java\lib. To change the location, type envset java_home=jvmlocation, where jvmlocation is the directory where you’ve stored the new JVM. Don’t change this variable unless you’ve installed a different JVM on your NetWare server. Otherwise, Java won’t run on your server.
The OSA_HOME environment variable specifies the location of Java libraries. The default value is SYS:\java. To set this variable, type envset osa_home=location, where location is the directory of the Java libraries. Be careful when changing this variable. If you set it wrong, your Java applications may not run.
The XLOCALEDIR environment variable tells NetWare’s JVM where to find files needed to support other languages. This variable also tells the JVM where to find keyboard and font files. The default location of the locale files is SYS:\java\nwgfx\locale. To change this variable, type envset xlocaledir= location.
Environment variables that you set using envset only last until you unload Java on your server. If you unload and reload JAVA.NLM, all environment variables revert to their defaults. To make environment variable settings permanent, you must add the commands to the server’s JAVA.CFG file. You’ll find this file in the SYS:\Etc directory. You can edit it with any text editor, including EDIT.NLM, directly on your server.
By using Java, you’re not limited to only running NLMs on your NetWare server. You can run the same Java applications on your NetWare server that you do on any other Java-enabled computer. Java allows your NetWare server to perform as an application server as well as it performs as a file and print server.