?
Solved

running a java application rather a browser

Posted on 2005-04-19
17
Medium Priority
?
219 Views
Last Modified: 2013-11-23
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
Comment
Question by:desiboy1974
  • 4
  • 3
  • 3
  • +4
17 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 13821418
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13821427
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
 
LVL 16

Expert Comment

by:suprapto45
ID: 13821429
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 16

Expert Comment

by:suprapto45
ID: 13821432
Hi aozarov,

nice to meet you :).

Regards
Dave
0
 

Author Comment

by:desiboy1974
ID: 13821467
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13821468
Hi, suprapto45
I am going to sleep now. so I will leave the place for you ;-)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 13821548
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 2000 total points
ID: 13821578
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
 
LVL 92

Expert Comment

by:objects
ID: 13821586
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
 
LVL 24

Expert Comment

by:sciuriware
ID: 13821606
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
 
LVL 24

Expert Comment

by:sciuriware
ID: 13821618
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
 

Author Comment

by:desiboy1974
ID: 13821683
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
 
LVL 92

Expert Comment

by:objects
ID: 13821703
Web Starts best for that, see the details posted earlier by sudhakar_koundinya.
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 13821747
Sorry for the delay but I think that everything is covered already.

So good luck

regards
Dave
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13822095
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13823822
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question