• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

running a java application rather a browser

can someone tell me how to run a java application straight as a double click from the desktop rather than on a web browser..

basically i have a java chat applet that runs in a browser..so a php page calls the java applet..i want to get rid of the browser and just run it as a application on the client's PC...so when he double clicks on an icon on the desktop it will run the java applet..the java files all sit on the server though..i have the java runtime running on every clients PC..also a paremeter gets passed to the browser currently which is the clients ID..so i'd like to pass that too when running it as a applications..thanks
0
desiboy1974
Asked:
desiboy1974
  • 4
  • 3
  • 3
  • +4
1 Solution
 
suprapto45Commented:
Mmm....

On my opinion is that you need to create either .bat file that will execute your applet class or you need to create .exe file for your applet. Normally, .bat file would be sufficient but assuming that your client has JVM installed.

let me try to find the URL to help you.

Regards
Dave
0
 
aozarovCommented:
You can invoke the appletviewer programatically by calling the main method of java sun.applet.Main
e.g java sun.applet.Main http://www.vipan.com/htdocs/swing.html
0
 
suprapto45Commented:
Hi,

How about these URL..

http://www.builderau.com.au/askexperts/java/0,39024791,20283101,00.htm

JAR File
http://java.sun.com/docs/books/tutorial/jar/basics/index.html

For example, you have 12 classes for your applet. You need to bundle them into one .jar file and create .bat to execute the main class.

I hope that helps.

Regards
Dave
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
suprapto45Commented:
Hi aozarov,

nice to meet you :).

Regards
Dave
0
 
desiboy1974Author Commented:
i have all the files in a jar..

currently i call it in a browser

<body>
<applet archive='peoplechat.jar,classes12.jar' code='ClientApplet.class' name='bdon' alt='asd' width=700 height=700 MAYSCRIPT>
<PARAM NAME='custService' VALUE=\"$custService\">
</applet>
</body>

This is what i want to convert to a application..if i use a .bat file ..how will it reference the jar files that run on the server when the .bat file runs on  the client?
0
 
aozarovCommented:
Hi, suprapto45
I am going to sleep now. so I will leave the place for you ;-)
0
 
sudhakar_koundinyaCommented:
0
 
sudhakar_koundinyaCommented:
0
 
sudhakar_koundinyaCommented:
here is the typical example how Java Web start file will be(.jnlp)

You can get some examples from  java.sun.com  regarding this concept

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for SpringBox -->
<jnlp
  spec="1.0+"
  codebase="http://java.sun.com/docs/books/tutorialJWS/uiswing/layout/example-1dot4"
  href="SpringBox.jnlp">
  <information>
    <title>SpringBox</title>
    <vendor>The Java(tm) Tutorial: Sun Microsystems, Inc.</vendor>
    <homepage href="http://java.sun.com/docs/books/tutorial/uiswing/layout/example-1dot4/index.html#SpringBox"/>
    <description>SpringBox</description>
    <description kind="short">PENDING</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.4+"/>
    <jar href="allClasses.jar"/>
  </resources>
  <application-desc main-class="SpringBox"/>
</jnlp>
0
 
objectsCommented:
First you'll need to convert your applet to an application.
Then jar up the classes as an executable jar.
http://java.sun.com/docs/books/tutorial/jar/basics/run.html
0
 
sciuriwareCommented:
Hey desiboy1974, you can run any jar by double clicking,
both on MSWindows as on LINUX.
For MSWindows: as soon as you install JAVA (SUN) the relation is made to execute .jar (see registry)
with javaw (no console window).

If this is not the case on your machine, execute the next file "jar.reg" :
//////////////////////////////start
REGEDIT4

[HKEY_CLASSES_ROOT\.jar]
@="jarfile"

[HKEY_CLASSES_ROOT\jarfile]
@="Executable Jar File"

[HKEY_CLASSES_ROOT\jarfile\shell]

[HKEY_CLASSES_ROOT\jarfile\shell\open]

[HKEY_CLASSES_ROOT\jarfile\shell\open\command]
@="\"C:\\Program Files\\Java\\j2re1.4.2_04\\bin\\javaw.exe\" -jar \"%1\" %*"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jar]
@="jarfile"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile]
@="Executable Jar File"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jarfile\shell\open\command]
@="\"C:\\Program Files\\Java\\j2re1.4.2_04\\bin\\javaw.exe\" -jar \"%1\" %*"
//////////////////////////end
You should replace the "j2re1.4.2_04" by the version of JAVA you are running.

Next: every .jar must contain a manifest file to indicate the starting class;
example manifest: "Manifest.mf"
//////////////////start
Manifest-Version: 1.0
Created-By: 1.4.2_03 (Sun Microsystems Inc.)
Main-Class: MyMainClass

//////////////////end
Notes:
1) the version info in the manifest is not significant (yet),
2) replace "MyMainClass" by the name of yours,
3) line 4 is indeed empty, don't delete it!
4) the structure of the .jar file is important:
    in the 'top' directory your (main) classes should be AND a directory named "Meta-inf";
    the manifest file should be in that last directory.

The 'jar' command and almost all IDE's will create a .jar file to these specifications.

Success!

;JOOP!
0
 
sciuriwareCommented:
P.S.: an applet must be called from a 'main' class as if that were the browser.
You could also modify the Applet into a main class from:

//////////////////start
public class MyFormerApplet
{
      public static void main(String[] commandline)
      {
................
      }
}
//////////////////////end

;JOOP!
0
 
desiboy1974Author Commented:
after convertying the applet to an application and jarring up the classes

how do i reference the executable from the client PC when the files reside on the server?
0
 
objectsCommented:
Web Starts best for that, see the details posted earlier by sudhakar_koundinya.
0
 
suprapto45Commented:
Sorry for the delay but I think that everything is covered already.

So good luck

regards
Dave
0
 
CEHJCommented:
You can try just adding the applet to a frame. If you can let us know where it is, we may be able to try this
0
 
aozarovCommented:
If you don't mind to keep it as an Applet (and you don't want to use the browser) then why not to use the appletviwer.
And as I suggested you can do that by either embeding it inside your code (by invoking java sun.applet.Main or using sun.applet.AppletViewer directly [see tools.jar for those classes])
or launching the appletviwer from a script (as suprapto45 suggested). Doing so will require no code change.
And as for where to put 'peoplechat.jar' and 'classes12.jar' just put them in the same folder as ClientApplet.class
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 4
  • 3
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now