View comments | RSS feed

Command-line tools

JRun includes several command-line tools that make some tasks easier to perform. This section describes the command-line tools included with JRun. Some tools are described in more depth in other books within the documentation set. These tools and references to the other documentation are noted.

To invoke the Java-based command-line tools described in this section, you must include jrun_root/lib/jrun.jar in your Java classpath. If the tool has a shell script or executable, you must include the jrun_root/bin directory in your system path or execute the command from that directory.

Using the GetControlPort tool

The GetControlPort tool scans a range of ports and returns the first available one. GetControlPort is in the allaire.jrun.install package.

You can invoke the GetControlPort tool from the command line or from within a Java application. GetControlPort uses the following command-line syntax:

%> java [-classpath classpath] allaire.jrun.install.GetControlPort min_port max_port [output_file]

For example, to find the first open port between 51000 and 51999, use the following command:

%> java -classpath c:/jrun4/lib/jrun.jar allaire.jrun.install.GetControlPort 51000 51999

The GetControlPort class has one public method, scan. This method takes two arguments, the lower and upper limits of the range. The arguments are of type String. You can also pass in an array of strings (shown in the following example). GetControlPort returns the first open port within the range. If it encounters an error, GetControlPort returns -1.

The following code gets an open port between 51000 and 51999 in a Java class:

...
String[] portrange = new String[2];
String openport = new String;
portrange[0] = "51000";
portrange[1] = "51999";
GetControlPort gcp = new GetControlPort();
openport = gcp.scan(portrange);
out.println("The first open port between " + portrange[0] + " and " + portrange[1] + " is " + openport);
...

There are a number of ports used by JRun servers, and you must be aware of their settings and uses when administering JRun. This is especially important when adding new JRun servers. For more information about ports used by JRun, see JRun Administrator's Guide.

Using the migration tool

JRun provides a migration tool for moving JRun 3.x servers and configuration settings to JRun 4. Although you can deploy JRun 3.x J2EE modules in JRun 4 without using the migration tool, the tool exports many of the settings on which modules depend.

You can invoke the migration tool from the command line in the jrun_root/bin directory. The migrate tool uses the following command-line syntax:

%> migration jrun3.x_root

where jrun3.x_root is the root directory of a JRun 3.1 installation.

After successfully running the migration tool, open the jrun_root/migration.html file in a web browser. The migration.html page is a migration activity report that indicates what the tool successfully migrated and what it could not migrate.

For more information on using the migration tool, see Installing JRun.

Using Base64 encoder

The Base64 utility takes a string returns its base 64 encoded value. This encoding is used by web browsers when authenticating users with BASIC authentication. It is not a secure encoding mechanism, but is widely used for obfuscating nonsensitive data.

The Base64 utility is in the jrunx.util package. It uses the following syntax:

%> java [-classpath classpath] jrunx.util.Base64 string

For example:

%>java -classpath .;c:/jrun4/lib/jrun.jar jrunx.util.Base64 danger

This example returns the following to the standard output:

Input   = 'danger'
Encoded = 'ZGFuZ2Vy'
Decoded = 'danger'

The Base64 class also provides public encode and decode methods that you can invoke with an instance of the class. For more information, see the JRun Javadocs.

Using the Web Server Configuration tool

You use the Web Server Configuration tool to connect JRun to your external web server. The Web Server Configuration tool is implemented in the executable JAR file wsconfig.jar. It is in the jrunx.connectorinstaller package.

The Web Server Configuration tool uses the following syntax:

%> java -jar jrun_root/lib/wsconfig.jar [options]

To use a property file for options, use the following syntax:

%> java -jar jrun_root/lib/wsconfig.jar -f property-file

The property file contains tags that are equivalents of command-line options. This is commonly used by OEMs and ISVs who do not want to expose JRun to their customers.

For more information on using the Web Server Configuration tool command-line options, see Installing JRun.

Using the jrun command

The jrun command lets your start, stop, and restart JRun servers and get information about the version of JRun that you are currently running. You can use the JRun command-line tool with the jrun.exe (Windows) and jrun shell script (UNIX).

The jrun command uses the following syntax from the jrun_root/bin directory:

%> jrun [options] [server_name]

The following table describes the options:
Option
Description
-start
Starts JRun.
-stop
Stops JRun.
-restart
Restarts JRun.
-status
Displays status information for all JRun servers or for a specified JRun server.
-nohup
Starts JRun in a separate process.
-version
Displays the JRun version number (primarily for OEM use).
-build
Displays the JRun build number (primarily for OEM use).
-info
Displays additional information (primarily for OEM use).
-config
Specify a jvm.config file. The default is jrun_root/bin/jvm.config.

If you specify an option, such as start or stop, but do not specify a server_name, then JRun executes that command on all JRun servers.

If you do not specify any arguments, JRun opens the JRun Launcher.

For more information on using the JRun command-line tool, see JRun Administrator's Guide.

Using the jrunsvc tool

Use the jrunsvc tool to execute command on a JRun server that is a Windows service. With this tool, you can install, remove, start, and stop the JRun server's Windows service.

To install a JRun server as a Windows service, use the following syntax from the jrun_root/bin directory:

%> jrunsvc -install jrun_server [service_name [service_display_name [service_description]]]

To remove, start or stop a JRun server that is currently a Windows service, use the following syntax from the jrun_root/bin directory:

%> jrunsvc -[remove|start|stop service_name]

Using the JSPC tool

The JSPC tool compiles Java files. You can use it to precompile JSP pages, servlets, and other Java files. JSPC uses the following syntax from the jrun_root/bin directory:

%> jspc [-w web_app_root] [-d output_directory] [-k] [-v] [JSP_pages]

The -k option instructs JSPC to continue compilation even if it encounters errors.

The -v option instructs JSPC to run in verbose mode.

JSPC uses the IBM jikes compiler when it is in the jrun_root/bin directory; otherwise it uses the Sun javac compiler.

For more information on using the JSPC command-line tool, see JRun Assembly and Deployment Guide.

Using XMLScript

JRun includes XMLScript, an XPath-based XML scripting utility that lets you execute a subset of XPath statements on XML files.

With XMLScript, you can search an XML file for an expression, and then append or substitute values in nodes, or delete a node. You can also view the resulting nodes of an XPath expression. You can save the results to a new XML file or replace the original XML file.

XMLScript is in the jrunx.xml package. It uses the following syntax:

%> java [-classpath classpath] jrunx.xml.XMLScript [-i input-file] [-o output-file] 
  [-f script-file] -[a|d|s|v statement ...]

To use XMLScript, you must include jrun_root/lib/jrun.jar in your classpath.

For example:

%>java -classpath c:/jrun4b2/lib/jrun.jar jrunx.xml.XMLScript 
  -i c:/jrun4b2/servers/default/server-inf/jrun.xml 
  -s //service[@name='WebService']/attribute[@name='port']/text() 8842

You can also use the following syntax from the jrun_root/bin directory:

%> xmlscript [options]

For more information on using XMLScript, including examples see JRun Programmer's Guide.

Using Java2WSDL

The Java2WSDL tool generates a WSDL document for a Java interface or class that you want to use as the basis for a web service. After generating a WSDL document with Java2WSDL, you can use the WSDL2Java tool to generate the appropriate proxy and skeleton code and deployment descriptor information for the web service.

Java2WSDL is part of the org.apache.axis.wsdlgen package. The Java2WSDL tool uses the following syntax:

%> java [-classpath classpath] org.apache.axis.wsdlgen.Java2WSDL [options]

You must include the following files in your classpath:

You can also use the following syntax from the jrun_root/bin directory:

%> java2wsdl [options]

For information about the Java2WSDL command-line options, see JRun Programmer's Guide.

Using WSDL2Java

The WSDL2Java tool generates web service proxy and skeleton code based on information in a web service WSDL document. WSDL2Java generates proxies from WSDL documents that specify RPC encoded, document literal, and document encoded SOAP encoding styles.

WSDL2Java is part of the org.apache.axis.wsdl package. The Java2WSDL tool uses the following syntax:

The WSDL2Java tool uses the following syntax:

%> java [-classpath classpath] org.apache.axis.wsdl.WSDL2Java [options]

You must include the following files in your classpath:

You can also use the following syntax from the jrun_root/bin directory:

%> wsdl2java [options]

The WSDL2Java tool includes username and password options. You can use these when the WSDL file is protected by Basic authentication using the web server and you try to access the URL in a web browser. For example:

wsdl2java -U nickd -P password http://host/protected/file/here.wsdl

For more information about the WSDL2Java command-line options, see JRun Programmer's Guide.

Comments


gmarziou said on Aug 12, 2002 at 1:35 PM :
Error in docuumentation:

The tool for migration from JRun 3 to JRun 4 is bad is refered as 'migration', in realty, the tool is named 'migrate'.
deckerd26354 said on Jun 7, 2004 at 7:22 PM :
Here's a WSH wrapper for the command:

' get command line args
Set objParms = Wscript.Arguments

' we need at least two port numbers
If objParms.Count < 2 Then
varRetVal = MsgBox("Syntax: GetAvailablePort [lowPortNumber] [HighPortNumber]", _
64,"JRun GetControlPort Tool Runner")
Wscript.Quit
End If

' get the port numbers
strLowPortNumber = LCase(Trim(objParms(0)))
strHighPortNumber = LCase(Trim(objParms(1)))

' run the command and capture the output. Assuming that the
' appropriate java.exe is in the system PATH and that the jrun.jar
' is in the system CLASSPATH
strOutput = ""
Set objShell = Wscript.CreateObject("WScript.Shell")
Set objRetVal = objShell.Exec("java allaire.jrun.install.GetControlPort " & _
strLowPortNumber & " " & strHighPortNumber)

While Not objRetVal.StdOut.AtEndOfStream
strOutput = strOutput & objRetVal.StdOut.ReadLine() & VbCrLf
Wend

' build output message
strOutput = "First Avail Port in [" & strLowPortNumber & ":" & _
strHighPortNumber & "] is: " & Trim(strOutput)

' display message
objShell.Popup strOutput, 5, "JRun GetControlPort Tool Runner", 64

' cleanup
Set objShell = Nothing
Set objParms = Nothing

:)

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/jrun/4/JRun_SDK_Guide/apis4.htm