|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
General Java Deploying and Removing Patches for Java Applications
Deploying and Removing Patches for Java Applications
By: Chris White; John R. Hines
Jan. 1, 2001 12:00 AM
The term deploy describes the process of installing the pieces of an application to a host and making whatever modifications are required to the host environment so the application runs correctly without further modifications. A patch is a group of Java class files, one or more documentation files, and one or more batch files that installs them to modify the behavior of a deployed program. Deploying a Java application, particularly a distributed Java application, is a complex task, since applications typically require installing a number of jar files and batch files (sometimes to different locations) as well as making changes in the host's environment. Most developers create a custom install program to simplify deployment. (Usually the developer employs a deployment program builder like InstallAnywhere to create the program.) Generating the install program is time consuming, and it must be tested and verified before it and its related application can be shipped to customers. This is a particularly slow process if the install procedure must work on many platforms (Linux, Mac, Unix, Windows, etc.). The cost and time required to create and test an install program become significant obstacles to the timely delivery of upgrades and bug fixes. However, minor upgrades and simple bug fixes for a single platform can be quickly implemented with a patch. (Note: Patching other platforms usually requires only minor modifications to the patch batch file.) Patches take advantage of a Java feature called the classpath, a list of locations where the Java launcher (Java.exe) searches for Java class files. The launcher searches the first location, then the second, and so on. If a suitable class is found, the launcher stops searching. If none is found, a "No Class Found" error message is generated. When the application is deployed, if the developer is wise enough to consider the possibility of needing a patch, the first location is empty, the jar files are deployed to the second, third, and so on, locations. When stand-alone class files for a patch are placed in the first search location, they take precedence over the class files deployed in jar files in that location and over stand-alone class files and class files deployed in JAR files in all following locations, effectively replacing them.
Classpath Details
A typical classpath in Windows looks like this: .;C:\MyClasses;C:\MyOtherClasses\SomeJar.jar In other words, search the directory where the batch file that called the launcher was started, then the directory C:\MyClasses, then the jar file C:\MyOtherClasses\SomeJar.jar. Note: When searching locations, the launcher searches for a fully qualified class file (package plus a dot plus class name) and uses the package name as a directory hierarchy. Given the above classpath, if the launcher was searching for someRootPackage.someSubPackage.ThisClass, it would search for the file ThisClass.class in the directory someSubPackage under someRootPackage:
Setting the Classpath
The -cp option allows the developer to specify a classpath that's valid for the Java launcher until it terminates. Consider this Unix command line: java -cp .:A.jar:B.jar com.myPackage.MyClass
Note: If java.exe is started without the -cp command line and if no classpath environment variable is specified, only the default location of the libraries is searched. (The default location is the lib directory under the same directory as the bin directory where java.exe is stored.) Warning: A classpath variable containing many search paths significantly increases search time!
An Example
Suppose you need to patch the jar file SomeJarFile.jar in the directory/home/ myname/someproduct by replacing the file com.somePackage.MyClass.class with the file J:\MyClasses\com\some Package\MyClass.class. Also, suppose the program in the jar file is started by a batch file in the same directory as the jar file using the line: java -cp SomeJarFile.jar com.somePackage.SomeClass
A Name
A Directory
A Zip File
A Readme File
readme2000082301.txt describes the patch patch2000082301. Add this file to the Zip file. Don't add any location information for this file!
Map a Drive to the Appropriate Root Directory
Add the Class File to the Zip File
Add a Remove Batch File
echo batch file to remove patch patch2000082301 Add this file to the Zip file. The batch file must not contain any ^M characters at the end of a line or they'll be treated as part of the file name and the RM command will not work correctly. Since this file is inside a Zip, the "transfer binary" ftp option won't strip out the ^Ms.
Copy the Zip File
Modify the Start File
java -cp .:SomeJarFile.jar com.somePackage.SomeClass This change forces the loader to first search for new class files under the directory where the jar file is deployed before it searches the jar file. (Hopefully, this change has already been made.)
Unjar the Zip File
jar -xvf patch2000082301.zip
Restart the Program
A Possible Problem
Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||