[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 900
  • Last Modified:

java web start

hi...i'm a little new to java web start..am trying to launch a jnlp file on my local PC..i have the runtime as well as sdk installed too...this is my jnlp file....how do i launch the jnlp file without deploying it onto the web server..

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SwingSet2 Demo Application -->
<jnlp
  spec="1.0+"
  codebase="http://my_company.com/jaws/apps"
  href="swingset2.jnlp">
  <information>
    <title>SwingSet2 Demo Application</title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <homepage href="http://www.hotmail.com"/>
    <description>SwingSet2 Demo Application</description>
    <description kind="short">A demo of the capabilities of the Swing Graphical User Interface.</description>
    <icon href="intro.jpg"/>
    <icon href="ok.jpg"/>
    <icon href="nothanks.jpg"/>
    <offline-allowed/>
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
    <j2se version="1.4.2"/>
    <jar href="lib/peoplechat.jar"/>
    <jar href="lib/classes12.jar"/>
  </resources>
  <application-desc main-class="PeopleClientApplet"/>
</jnlp>

0
trance12
Asked:
trance12
  • 38
  • 31
  • 27
2 Solutions
 
objectsCommented:
if the correct file association is setup you should be able to double click on it
0
 
objectsCommented:
For example under windows the association would be something like:

"C:\Program Files\Java\j2re1.4.2_05\javaws\javaws.exe" "%1"
0
 
trance12Author Commented:
all the jar files, the class files etc are under one folder..and i've placed my jnlp file under that folder too..so just double clicking it would work?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
easy way to find out :)
0
 
aozarovCommented:
>> ..so just double clicking it would work?
If you want to run it localy and without http server you will need to change the codebase to something like that:
codebase="file:/c:/java-temp/jnlp"  (replace the path location with the location of your jnlp folder).
0
 
trance12Author Commented:
i double clicked aqnd it asked me for a useranem and password..i've changed the codebase to

file:/C:/java_source cause thats where all the files reside.


0
 
aozarovCommented:
>> i double clicked aqnd it asked me for a useranem and password
I assume because that application requires it.

>> file:/C:/java_source
if java_source is a folder it should be ended "/"
0
 
objectsCommented:

>   <application-desc main-class="PeopleClientApplet"/>

Make sure that class is an application and not an applet, ie. has a main() method that starts it up
0
 
trance12Author Commented:
it has a main methid in it..

 static public void main( String args[] )  {
       
        new PeopleClientApplet();
    }

it still asks me for a username and password thoug
0
 
aozarovCommented:
Who is asking? is it webstart or is the application that was invoked by webstart?
0
 
objectsCommented:
You're accessing some resource that requires authentication.
0
 
aozarovCommented:
I have the feeling that your application is working right.
This seems to be a chat application and probably wants you to enter username/password in order to login to the chat, no?
0
 
objectsCommented:
What happens when you run it directly from the command line?
(And why use Web start if you're only running it locally)
0
 
trance12Author Commented:
no..we dont have  a username and password...its java web start start thats asking me for username and password when it tries to start the application..could it be bacause the jar files are signed?
0
 
trance12Author Commented:
same thing...when i run it from the command line, it automatically launches it through web start
0
 
trance12Author Commented:
should i disable web start and try?
0
 
aozarovCommented:
>> application..could it be bacause the jar files are signed?
That is needed to invoke it localy and get all permissions (as the jnlp suggest).
Normally you just need to accept the CA (and not provide username/password).
0
 
aozarovCommented:
>> same thing...when i run it from the command line, it automatically launches it through web start
How do you run it?
Run it using java -classpath lib/peoplechat.jar;lib/classes12.jar PeopleClientApplet
0
 
objectsCommented:
> .its java web start start thats asking me for username and password when it tries to start the application..could it be bacause the jar files are signed?

As I said above, jws is trying to access some resource that is requesting authentication.
Hard to say what it is from here sorry :(

> when i run it from the command line, it automatically launches it through web start

Just run it with java.exe (assuming you are on windows) with the appropriate classpath
0
 
trance12Author Commented:
this works fine..java -classpath lib/peoplechat.jar;lib/classes12.jar PeopleClientApplet

though i want to run it using the jnlp file..cause later i want to deply it onto the server
0
 
objectsCommented:
Are you just running it locally? If so why even use jws?
0
 
objectsCommented:
> cause later i want to deply it onto the server

Then I'd suggest doing your testing on the web server.
0
 
aozarovCommented:
Try to input some username/password and accept it. see what happens.
Also, does it mention (in the username/password part) some more information?
0
 
trance12Author Commented:
i'll try it on the web server...if so do i just lauch the jnlp file via the web browser?

0
 
objectsCommented:
yes
0
 
aozarovCommented:
>> i'll try it on the web server...if so do i just lauch the jnlp file via the web browser?
Make sure your webserver provide the jnlp file with the right mime-type "application/x-java-jnlp-file"
0
 
trance12Author Commented:
>>>Make sure your webserver provide the jnlp file with the right mime-type "application/x-java-jnlp-file"

how do i do that?
0
 
aozarovCommented:
Depends on your http server. which one are you using.
besically most contain a mapping from suffix to mime-type value and this is where you want to add it.
jnlp -> application/x-java-jnlp-file
0
 
aozarovCommented:
0
 
trance12Author Commented:
apache..is iit in the httpd.conf file?
0
 
aozarovCommented:
no, see the above link (or this link):
http://www.jfimagine.com/en/faq.htm#jnlp-mime
0
 
trance12Author Commented:
ok..i've added it in the mime.types file...have placed the jnlp file in the same folder where the jar files and class files sit..wheni give a link to the jnlp file via the web page, it just opens up the jnlp file???
0
 
trance12Author Commented:
i've given the web link this way

http://192.168.8.47/chat/swingset2.jnlp
0
 
objectsCommented:
you can add the following to .htaccess file in top level directory

AddType application/x-java-jnlp-file    .jnlp
AddType application/x-java-archive-diff .jardiff


0
 
objectsCommented:
did u restart web server?
0
 
aozarovCommented:
Did you restart Apache after adding the entry to the mime.types file?
0
 
trance12Author Commented:
yep..
0
 
trance12Author Commented:
this is what i entered in the mime.types file

application/x-java-jnlp-file

and restarted the server
0
 
trance12Author Commented:
this is my jnlp file

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SwingSet2 Demo Application -->
<jnlp
  spec="1.0+"
  codebase="http://192.168.8.47/chat/"
  href="swingset2.jnlp">
  <information>
    <title>SwingSet2 Demo Application</title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <homepage href="http://www.hotmail.com"/>
    <description>SwingSet2 Demo Application</description>
    <description kind="short">A demo of the capabilities of the Swing Graphical User Interface.</description>
    <icon href="intro.jpg"/>
    <icon href="ok.jpg"/>
    <icon href="nothanks.jpg"/>
    <offline-allowed/>
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
    <j2se version="1.4.2"/>
    <jar href="peoplechat.jar"/>
    <jar href="classes12.jar"/>
  </resources>
  <application-desc main-class="PeopleClientApplet"/>
</jnlp>

0
 
aozarovCommented:
You are missing the jnlp part (see below)
application/x-java-jnlp-file jnlp
0
 
aozarovCommented:
you should associate the mime type to a suffix (jnlp) which you were missing.
0
 
trance12Author Commented:
i did that too..

application/x-java-jnlp-file jnlp

and restarted the web server..same issue..just opens up the jnlp file
0
 
objectsCommented:
If you are editting mime.types the line to add should be:

application/x-java-jnlp-file jnlp
0
 
objectsCommented:
What browser are you using?
0
 
trance12Author Commented:
IE 6.0.2900

0
 
aozarovCommented:
Goto Control Panel/Java
then pick Advance then goto <APPLET> tag support and make sure IE is checked.
Basically IE should be using the JavaPlugin.
0
 
objectsCommented:
You can set Sun plugin as default vm from Advanced internet options in IE
0
 
trance12Author Commented:
sun plugin is already the default vm...
0
 
trance12Author Commented:
if i look in advanced internet options, the java VM is already ticked
0
 
objectsCommented:
try telnetting to your web server and request the jnlp file, that should tell you the mime type being used.

GET /chat/swingset2.jnlp HTTP/1.0
0
 
aozarovCommented:
You can also call it directly (from the command line)
javaws http://192.168.8.47/chat/swingset2.jnlp
This will load it from your webserver but without a browser.
0
 
aozarovCommented:
Also (regarding IE) make sure that Control Panel/Java/Advanced/JNLP-File/Mime Association is not set to "never allow"
0
 
trance12Author Commented:
it doesnt like the javaws command when i run it from command prompt??


C:\java_source>javaws
'javaws' is not recognized as an internal or external command,
operable program or batch file.
0
 
trance12Author Commented:
telnet is not enabled on the web server..any other way i can try it?..maybe on the web server?
0
 
aozarovCommented:
Are you sure java webstart is installed?
if so it seems java/bin folder is not in your path.
Do:
%JAVA_HOME%\bin\javaws http://192.168.8.47/chat/swingset2.jnlp
where JAVA_HOME is where you installed your JDK.
0
 
aozarovCommented:
>> telnet is not enabled on the web server..any other way i can try it?..m
YOu don't need it there only local telnet client
telnet 192.168.8.47 80
GET /chat/swingset2.jnlp HTTP/1.0<new_line>
<new_line>

where <new_line> is pressing enter
0
 
objectsCommented:
What version of Java have you installed, 1.4+ is probably best.
0
 
trance12Author Commented:
yep..this is what i get when i telnet

HTTP/1.1 200 OK
Date: Tue, 10 May 2005 04:35:54 GMT
Server: Apache/2.0.49 (Win32) mod_ssl/2.0.49 OpenSSL/0.9.7d
Last-Modified: Tue, 10 May 2005 02:53:28 GMT
ETag: "18335-39c-a9314fe2"
Accept-Ranges: bytes
Content-Length: 924
Connection: close
Content-Type: application/x-java-jnlp-file

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SwingSet2 Demo Application -->
<jnlp
  spec="1.0+"
  codebase="http://192.168.8.47/chat/"
  href="swingset2.jnlp">
  <information>
    <title>SwingSet2 Demo Application</title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <homepage href="http://www.hotmail.com"/>
    <description>SwingSet2 Demo Application</description>
    <description kind="short">A demo of the capabilities of the Swing Graphic
User Interface.</description>
    <icon href="intro.jpg"/>
    <icon href="ok.jpg"/>
    <icon href="nothanks.jpg"/>
    <offline-allowed/>
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
    <j2se version="1.4.2"/>
    <jar href="peoplechat.jar"/>
    <jar href="classes12.jar"/>
  </resources>
  <application-desc main-class="PeopleClientApplet"/>
0
 
aozarovCommented:
That looks good.
Did you find your webstart in %JAVA_HOME%\bin\javaws ? (so you can run it directly)?
0
 
objectsCommented:
What version of the JRE do you have installed (not the JDK)
0
 
trance12Author Commented:
yep..its "C:\Program Files\Java\j2re1.4.2\javaws\javaws.exe"

JRE version is 1.4.2
0
 
trance12Author Commented:
i ttied it form the command prompt using the javaws command too

javaws http://192.168.8.47/chat/swingset2.jnlp

and it gave me the same user authentication screen asking for a username and password..
0
 
objectsCommented:
ANy firewalls or anything that would require authenticating?
0
 
trance12Author Commented:
its actually to do with java web start..if i just launch java web start without calling the jnlp file..it asks me for a username and password..
0
 
aozarovCommented:
Is it an option for you to re-install your java?
0
 
trance12Author Commented:
i can reinstall java web start..thats no problem
0
 
aozarovCommented:
in 1.4.2 it comes bundeld
0
 
objectsCommented:
Why reinstall?
0
 
aozarovCommented:
for one the reason that it doesn't work with IE.
for two the username/password when invoking webstart even without a program (which sounds strange).
Not sure if it will fix the last one but I think it is worth a try.
0
 
objectsCommented:
jws prompting for a password is not unusual.
0
 
aozarovCommented:
when launched without any arguments??
0
 
trance12Author Commented:
actually i tried it on the web server using the javaws command and it gave me a dojwload error

n error occurred while launching/running the application.

Title: SwingSet2 Demo Application
Vendor: Sun Microsystems, Inc.
Category: Download Error

The application has requested a version of the Java 2 platform (JRE) that is currently not locally installed. Java Web Start was unable to automatically download and install the requested version. The JRE version must be installed manually.

Error Code 11 (11  Could not locate requested version) returned from server when accessing resource: (http://java.sun.com/products/autodl/j2se, 1.4.2)
0
 
trance12Author Commented:
its running j2re1.4.2_07
0
 
aozarovCommented:
the jnlp specifies <j2se version="1.4.2"/>
and this is what you already have "C:\Program Files\Java\j2re1.4.2\javaws\javaws.exe"
so something in your settings doesn't look good.
0
 
objectsCommented:
> its running j2re1.4.2_07

are you sure thats the version you ran?

What other versions do you have installed?
0
 
objectsCommented:
Old versions (<1.4) can cause problems when 'mixed'
0
 
aozarovCommented:
Reinstalling yould probably help here ;-)
0
 
trance12Author Commented:
i only have 1.4.2_07 installed
0
 
objectsCommented:
Above you said you also had the jdk installed, what version  is it?
0
 
trance12Author Commented:
same version 1.4.2_07
0
 
objectsCommented:
can you load other applets ok?

http://www.objects.com.au/java/examples/swing/StyledList.do

And what about other jws apps?
0
 
trance12Author Commented:
yep..works fine with those apps
0
 
objectsCommented:
Have you tried loading your jnlp from a different machine?
0
 
trance12Author Commented:
i've tried it on the web server and 2 other machines and it give sme this

error occurred while launching/running the application.

Title: SwingSet2 Demo Application
Vendor: Sun Microsystems, Inc.
Category: Download Error

The application has requested a version of the Java 2 platform (JRE) that is currently not locally installed. Java Web Start was unable to automatically download and install the requested version. The JRE version must be installed manually.

Error Code 11 (11  Could not locate requested version) returned from server when accessing resource: (http://java.sun.com/products/autodl/j2se, 1.4.2)
0
 
trance12Author Commented:
got it to run without complainin...

i changed <j2se version="1.4.2"/>  to <j2se version="1.4"/>  and it did'nt complain

though it now launches and then suddenly closes..any ideas why that would happen

basically i want it to launch an applet

passing in 2 paramaters cust and custno..it also has 3 images to pass in..

should'nt the below work?

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SwingSet2 Demo Application -->
<jnlp
  spec="1.0+"
  codebase="file:///C:/java_source/"
  href="swingset2.jnlp">
  <information>
    <title>SwingSet2 Demo Application</title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <homepage href="http://www.hotmail.com"/>
    <description>SwingSet2 Demo Application</description>
    <description kind="short">A demo of the capabilities of the Swing Graphical User Interface.</description>
    <icon href="intro.jpg"/>
    <icon href="ok.jpg"/>
    <icon href="nothanks.jpg"/>
    <offline-allowed/>
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
    <j2se version="1.4.2"/>
    <jar href="lib/peoplechat.jar"/>
    <jar href="lib/classes12.jar"/>
  </resources>
  <application-desc main-class="PeopleClientApplet"/>
 <cust>kakaa</cust>
    <custno>1036339</custno>
</application-desc>
</jnlp>
0
 
objectsCommented:
Check the Java console for any errors
0
 
trance12Author Commented:
there's nothing in the console..it launches and then dies..??
0
 
objectsCommented:
so the console is empty, but the application does actually start does it? If so, does the app ignore any exceptions.
0
 
trance12Author Commented:
nothing on the console..when i run it using javaws..it goes to the part where it launches saying "java loading" and then dissapears..its actually an applet that i'm launching..
0
 
objectsCommented:
> its actually an applet that i'm launching..

jws is for running applications, just adding a main may not be enough for example if it expects to be run in a browser environment.
0
 
trance12Author Commented:
how to i run the applet using jnlp?
0
 
trance12Author Commented:
do you have any example that i can use just to check that the jnlp file launch works in java web..i can take it from there..
0
 
objectsCommented:
> how to i run the applet using jnlp?

you don't, its for running applications

> do you have any example that i can use just to check that the jnlp file launch works in java web

http://java.sun.com/docs/books/tutorialJWS/uiswing/14start/example-1dot4/HelloJWS.jnlp
0
 
trance12Author Commented:
the only difference between an applet and running an applet as an application is having a  main class right?
0
 
objectsCommented:
In one respect yes, but if its already written as an applet it may be expecting to be run in a browser, for example it may be looking for parameters from the applet tag. So just adding a main may not be enough to convert it.
Also the code you posted earlier does not call init() or start() which most likely need to be called if it is an applet.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 38
  • 31
  • 27
Tackle projects and never again get stuck behind a technical roadblock.
Join Now