Java Web Start "Hello, world!"?

I

Irving Kimura

Where can I find a minimal example ("Hello, world!") of a Java Web
Start application?

Thanks!

Irv
 
S

Svetozar Radojcin

Irving said:
Where can I find a minimal example ("Hello, world!") of a Java Web
Start application?

Suppose you have one 'ordinary', whatever Java desktop Swing
application.
You can pack her into one .jar archive, lets say ClientApp.jar

- deploy ClientApp.jar to the web server along with your .war archive
(to be more precise, .jar file must (?)
be member of your .war file)

- then, in your
HttpServlet.doPost(HttpServletRequest req, HttpServletResponse resp)
method, you can say:
.....
resp.setContentType("application/x-java-jnlp-file");
ServletOutputStream out = resp.getOutputStream();
out.println(buildJNLP(req, sId));
out.flush();
out.close();
....

-Finally, here is buildJNLP() method:

private String buildJNLP(HttpServletRequest req, String sid) {

String serverName = req.getServerName();
int serverPort = req.getServerPort();
String xmlHeader = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
String codebase = "<jnlp codebase=\"http://" + serverName +
":" + serverPort + "/someRoot\">\n";
String appInfo = "<information>\n" +
"<title>JWS Client app</title>\n" +
"<vendor>your_name</vendor>\n" +
"<description>....</description>" +
"<description kind=\"short\"></description>\n"
+
"</information>\n";
String rsrcInfo = "<resources>\n" +
"<j2se version=\"1.3+\"/>\n" +
"<jar href=\"ClientApp.jar\"/>\n" +
"</resources>\n";
String appDesc =

"<application-desc
main-class=\"yourpackage.ClientAppMainClass\">\n" +
"<argument>" + serverName + "</argument>\n" +
"<argument>" + serverPort + "</argument>\n" +
"<argument>" + sid + "</argument>\n";
String endOfFile = "</application-desc>\n</jnlp>\n";
return(xmlHeader+codebase+appInfo+rsrcInfo+appDesc+endOfFile);
}

- "...The Java web start installation registers the file extension
..jnlp and the MIME type application/x-java-jnlp-file with
Windows, so Java Web Start will be launched from both Netscape
Navigator and Internet Explorer (and most
other browsers) when a link to a JNLP file is activated..."

- That is, approximately, it ;-)

On that way , you can download and launch "Hello world", or any type of
Java desktop swing application...
 
A

Andrew Thompson

Svetozar Radojcin said:
.....
- then, in your
HttpServlet......
<snip code>

Interesting technique, Cvele, and one of
interest to myself (I am looking at doing
what you described), however I feel that
the requirement for a Java aware server
goes somewhat beyond the spec of what
the OP was proposing.

Not your average GeoCities based,
free site! ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Hello World 2
Hello world 1
Hello World 1
Hello 2
HELLO 2
Hello World! 2
Hello everyone ! 4
Hello 4

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top