Hello, world!
The Application class
HspAgent( String )constructs a helper for this purpose. Its argument is the domain name of the machine on which the Hsp is running. The method getHsp() returns a Remote reference to an Hsp. The statement: Environment environment = new Environment( null, null); establishes that this client: The logout()method ends the interaction of this application with the Hsp. The HelloTask class
The execute method encapsulates its task's computation.
Its return value is an Object. Viewing the execute method as a
function, its return value is the value of the function it computes. In
this case, we have a constant function whose value is the String
"Hello, world!".Compiling your applicationThis section of the tutorial has several parts:
Compile the .java filesBecause the JavaTM programming language requires a mapping between the fully-qualified package name of a class & the directory path to that class, you should decide on package & directory names before you begin writing any code written in the Java programming language. This mapping allows the compiler for the Java programming language to know which directory contains the class files mentioned in a program. For the programs in this tutorial, the package name is janet.examples.helloworld and the source directory is $HOME/janet/examples/helloworld, where $HOME is set to your home directory. Create the directories needed:
To compile the source files, run the javac command as follows: javac -d $HOME/classes -classpath .:$JANET/lib/janet-system.jar *.javaThis command creates the directory janet/examples/helloworld (if it does not already exist) in the directory $HOME/classes. The command then writes to that directory the files Application.class & HelloTask.class. For an explanation of javac options, you can refer to the Solaris javac manual page or the Win32 javac manual page. Deploy your applicationDeployment consists of:
Setting your codebaseSome web servers allow accessing a user's public_html directory via an HTTP URL constructed as "http://host/~username/". As an alternative, you can use an HTTP URL by setting up a minimal web server on your system; Sun Microsystems has one available for download here.To make the task classes accessible to Hosts (which will execute them), the task class files are copied from the development directory to the Application's codebase directory. First, create the directories where the class files will go: $HOME/classes/janet/examples/helloworld. Directories & class files must be readable & executable by all.Copy the task class files to the directory: cp $HOME/classes/janet/examples/helloworld/*.classMake the class files accessible for download: chmod 755 $HOME/public_html/classes/janet/examples/helloworld/*.classThe file permissions must allow these executable class files to be downloaded via a web server. Check permissions all the way down the path up to and including the class files themselves. A good way to ensure that the files are accessible via a web server is to point a web client to the directory that contains the files, and see if they are accessible (if they are, you will see a listing of the directory's contents). Start the HSP, a TaskServer, and a HostFollow the links on the Administration manual page to start the following Janet components: Hsp, TaskServer, & at least 1 Host.Start the applicationAccessing an HSPIf you do not have access to a running JANET hosting service provider, you will need to start one. (A hosting service providercomprises an Hsp, at least 1 TaskServer, and at least 1 Host). This is easy. Please see the System Administration Manual. Launch the JANET programTo start Application.class, execute (all on 1 line):
-Djava.rmi.server.codebase=http://<server-domain-name>/~<username>/classes/ -Djava.security.policy=$JANET/policy/policy janet.examples.helloworld.Application <hsp-machine> The output should look like this: Hello, world! |