Use Seppia To Run Your Application |
This article is written to show you how to use seppia to start up your application and how this operation can dramatically reduce your installation and deployment efforts.
An interesting and straight-forward way to use Seppia is as an application
launcher.
Suppose you have written your java application and suppose that your application
needs some third party software, let's say:
Your application is then jarred in a file called greatstuff.jar and
the entry point for your application is the class
com.company.greatstuff.core.Main
As you were developing it in your system you were probably launching it by calling the jvm like this (peraphs this call was thru your favourite ide but that does not matter):
java -cp c:\deployment\greatstuff.jar; c:\otherstuff\opensource\jakarta\log4j\lib\log4j-1.2.7.jar; c:\java\3rd\xercesImpl; c:\java\3rd\jcommons-0.9.6.jar; c:\java\3rd\lucene-1.4\lib\lucene.jar com.company.greatstuff.core.Main
As you prepare to deploy your application it is quite common this days to create a lib
directory.
So the way to launch it becomes:
java -cp c:\greatstuff\lib\greatstuff.jar; c:\greatstuff\lib\log4j-1.2.7.jar;
c:\greatstuff\lib\jcommons-0.9.6.jar; c:\greatstuff\lib\lucene.jar com.company.greatstuff.core.Main
which assumes that the final user has installed it in c:\greatstuff
To ease the process of installing and running your application you probably need
to provide some batches or scripts depending on the o.s. on the user's
machine.
Finally it is reasonable to think that your application might need to read some
property files or pass some values to the main method in order to start up
properly.
We are now going to show you how we are going to simplify all of this and let
the user start up your application by simply typing:
java -cp . StartUp
Embedding Your Application |
c:\greatstufforg.seppia.bootstrap log4j-1.2.7.jar, xercesImpl.jar, ...) in itStartUp.js javascript in org.seppia.bootstrap\javascripts to
call your application's entry point:
function main()
{
Packages.com.company.greatstuff.core.Main.main([]);
}
greatstuff
+ jars
+ modules
+ org.seppia.bootstrap
+ javascripts
| + StartUp.js
+ jars
+-- log4j-1.2.7.jar
+-- xerces.jar
+-- commons.jar
|
function main()
{
java.lang.System.setProperty("greatstuff.speed","20000");
java.lang.System.setProperty("greatstuff.frames","enabled");
var args = [ "header:25","nogui" ]
Packages.com.company.greatstuff.core.Main.main(args);
}
As you do this you might wonder whether you should not code those properties or args in the javascript.
Peraphs you might want to change your javascript to read them from another
file or to find them from another javascript. As you ponder over those
issues you might just realize that this is the whole point of Seppia: to
gain from the synergy of java and javascript, to combine java and
javascript in a new powerful way only you are coming to it from a
different angle.