Java Client and Direct To Java Client Example Project using WebStart

Version 23.1 by David Avendasora on 2008/06/25 09:43
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

  1. Create a new WebObjects Application
    Picture 9.png
  2. Name it "WebStartJNLPTest" in Eclipse with a package of "your.app" The [note] macro is a standalone macro and it cannot be used inline. Click on this message for details.
  3. Modify the Main.html by adding:
Main.html Changes
<WEBOBJECT NAME=JavaClientLink>click here</WEBOBJECT>
  1. Modify the Main.wod file by adding:
Main.wod Changes
JavaClientLink: WOHyperlink {
    href = javaClientLink;
}
  1. Modify the Main.java file by adding:
Main.java Changes

public String javaClientLink() {
return WOJavaClientComponent.webStartActionURL(context(), "JavaClient");
}
  1. Create a WOComponent named "JavaClient". This WOComponent will be what passes the specifics about your client-side application to WebObjects. 
  2. Modify the JavaClient.html replacing the contents with:
JavaClient.html Contents
<WEBOBJECT NAME=JavaClientComponent></WEBOBJECT>
  1. Paste the following as the contents of the JavaClient.wod file. Feel free to change the applicationName, applicationDescription and vendor parameters to anything you wish.
JavaClient.wod Contents

JavaClientComponent: WOJavaClientComponent {
    applicationClassName = "com.webobjects.eogeneration.EODynamicApplication";
    applicationName = "D2JC WebStart Test";
    applicationDescription = "D2JC WebStart Test";
    downloadClientClasses = "noDownloadClientClasses";
    vendor = "My Company";
}
Warning

Note!

If you are not creating a Direct To Java Client (D2JC) application, then you will need to replace the applicationClassName parameter (com.webobjects.eogeneration.EODynamicApplication) with the name of your client-side application class. Your non-D2JC client-side Application class *must* subclass EOApplication.

  1. Add the following frameworks to the project build path:
JavaDirectToWeb
JavaDTWGeneration
JavaEOApplication
JavaEOControl
JavaEODistribution
JavaEOGeneration
JavaEOInterface
JavaEOInterfaceSwing
JavaEOProject
JavaEORuleSystem
JavaFoundation
JavaJDBCAdaptor
JavaWebObjects
JavaWOExtensions
  1. Create a ClasspathClient.txt file in the root of the project and paste the following as contents:
ClasspathClient.txt File

# ApplicationClass == com.webobjects.eoapplication.client.EOClientApplicationSupport
# JDB              == jdb
# JDBOptions       ==
# JVM              == java
# JVMOptions       ==
APPROOT/WebServerResources/Java/WebStartJNLPTest.jar
/System/Library/Frameworks/JavaFoundation.framework/WebServerResources/Java/JavaFoundation.jar
WOROOT/Library/Frameworks/JavaEOControl.framework/WebServerResources/Java/JavaEOControl.jar
WOROOT/Library/Frameworks/JavaXML.framework/WebServerResources/Java/JavaXML.jar
WOROOT/Library/Frameworks/JavaDirectToWeb.framework/WebServerResources/Java/JavaDirectToWeb.jar
WOROOT/Library/Frameworks/JavaEOApplication.framework/WebServerResources/Java/JavaEOApplication.jar
WOROOT/Library/Frameworks/JavaEODistribution.framework/WebServerResources/Java/JavaEODistribution.jar
WOROOT/Library/Frameworks/JavaEOGeneration.framework/WebServerResources/Java/JavaEOGeneration.jar
WOROOT/Library/Frameworks/JavaEOInterface.framework/WebServerResources/Java/JavaEOInterface.jar
WOROOT/Library/Frameworks/JavaEOInterfaceSwing.framework/WebServerResources/Java/JavaEOInterfaceSwing.jar
WOROOT/Library/Frameworks/JavaEORuleSystem.framework/WebServerResources/Java/JavaEORuleSystem.jar
WOROOT/Library/Frameworks/JavaWOJSPServlet.framework/WebServerResources/Java/JavaWOJSPServlet_client.jar
HOMEROOT/Library/Java
LOCALROOT/Library/Java
WOROOT/Library/Java
/Network/Library/Java
WOROOT/Library/Frameworks/JavaVM.framework/Classes/classes.jar
WOROOT/Library/Frameworks/JavaVM.framework/Classes/ui.jar
  1. Create a javaclientbuild.xml file in root of the project and paste the follwing as contents:
javaclientbuild.xml

<project name="javaclient" default="javaclient" basedir=".">
<target name="setProps">
<property file="${user.home}${file.separator}build.properties"/>
<property file="build.properties"/>
<property file="${user.home}${file.separator}Library${file.separator}wobuild.properties"/>
<condition property="wo.properties.check.failed">
<not>
     <and>
       <isset property="wo.wosystemroot"/>
       <isset property="wo.wolocalroot"/>
     </and>
     </not>
   </condition>
   <fail message="Could not find ${user.home}${file.separator}Library${file.separator}wobuild.properties." if="wo.properties.check.failed"/>
</target>
<target name="javaclient" depends="setProps">
<mkdir dir="build/${project.name}.woa/Contents/WebServerResources/Java"/>

<!-- project client-side classes -->
<copy todir="build/${project.name}.woa/Contents/WebServerResources/Java/">
<fileset dir="${classes.dir}">
<include name="**/client/**/*.class,**/common/**/*.class,**/BMGenericRecord.class"/>
   <exclude name="**/server/**/*.class"/>
</fileset>
</copy>

<jar basedir="${classes.dir}"
includes="**/client/**/*.class,**/common/**/*.class,**/BMGenericRecord.class"
excludes="**/server/**/*.class"
jarfile="build/${project.name}.woa/Contents/WebServerResources/Java/${project.name}.jar">
</jar>

<!-- Launch Scripts and WOBootstrap.jar-->
<mkdir dir="build/${project.name}.woa/Contents/MacOS"/>
<mkdir dir="build/${project.name}.woa/Contents/UNIX"/>
<mkdir dir="build/${project.name}.woa/Contents/Windows"/>

<copy file="/Library/Application Support/Apple/Developer Tools/WebObjects Support/UnixLaunch.sh"
tofile="build/${project.name}.woa/Contents/${project.name}"/>
<chmod file="build/${project.name}.woa/Contents/${project.name}" perm="ugo+rx"/>
<copy file="/Library/Application Support/Apple/Developer Tools/WebObjects Support/WinLaunch.CMD"
tofile="build/${project.name}.woa/Contents/${project.name}.CMD"/>
<copy file="/Library/Application Support/Apple/Developer Tools/WebObjects Support/WOBootstrap.jar"
tofile="build/${project.name}.woa/Contents/WOBootstrap.jar"/>

<copy file="/Library/Application Support/Apple/Developer Tools/WebObjects Support/UnixLaunchClient.sh"
tofile="build/${project.name}.woa/Contents/MacOS/${project.name}_Client"/>
<chmod file="build/${project.name}.woa/Contents/MacOS/${project.name}_Client" perm="ugo+rx"/>
<copy file="ClasspathClient.txt" tofile="build/${project.name}.woa/Contents/MacOS/ClasspathClient.txt"/>

<copy file="/Library/Application Support/Apple/Developer Tools/WebObjects Support/WinLaunch.CMD"
tofile="build/${project.name}.woa/Contents/Windows/${project.name}.CMD"/>

</target>
</project>
  1. Right-click on the javaclientbuild.xml file and select "Run As -> Ant Build"
  2. Right-click on the project and select "Run As -> WebObjects Application"
  3. Select your.app.Application as the Application class
  4. Copy the Direct Connect URL from the Eclipse console and paste it into your browser. You should get a "click here" link.
  5. Click it.