Solved

Launching Java Application...

Posted on 2001-07-20
15
430 Views
Last Modified: 2013-11-23
I'm looking for instructions on how to launch a java application 'for dummies'.

If I send a jar file to somebody that knows nothing but the commandline to start the application... how do they do it on Windows98?  Do they need to install the java runtime?  Can they launch it from a dos prompt window or the 'run' box?  Can it be launched from a browser?  Since my appplication uses Jini do I include the needed Jini jar files?

This is the Client application only that will connect to the server over the network.

It requires the rmi daemon, how can this be run without leaving an open dos prompt?  Is it possible to run rmid.exe without leaving an open dos window?

Same for the Client applications... can it be run without leaving an open dos window?
0
Comment
Question by:WinDude
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 27

Expert Comment

by:rrz
Comment Utility
Have you condidered Java web start?
http://java.sun.com/products/javawebstart/index.html
0
 
LVL 1

Author Comment

by:WinDude
Comment Utility
Yes I have.  I guess I'm asking how to do it manually.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> how do they do it on Windows98?  

Few options:
- supply a batch
- make the jar executable
- supply a command line
- combinations of above

Depends a bit on the user and the app.

> Do they need to install the java runtime?

Yes.

> Can they launch it from a dos prompt window or the 'run' box?

Yes

> Can it be launched from a browser?

No

> Since my appplication uses
>Jini do I include the needed Jini jar files?

Yes

> It requires the rmi daemon, how can this be run without
> leaving an open dos prompt?  

Not sure if you mean on the client or server.
Depends on your OS I think. On NT I think you can set it up as a service.

> Is it possible
> to run rmid.exe without leaving an open dos window?

See above.

> Same for the Client applications... can it be run
> without leaving an open dos window?

Yes, javaw does not require a DOS window.
0
 

Accepted Solution

by:
prem_kumar79 earned 100 total points
Comment Utility
To run a java application with out using the command prompt the application class files and other files should be converted in to a JAR file.

Before that create a manifest file with the following code.    

Main-Class: TestClass (Your class name which contains the main method. Only the class name. No TestClass.class)

Final code

Jar Test.jar manifest.mf  class file names

For the above thing to work JRE as to be in place.

No need to include Jini jars files. Can be launched from the run box

RMI daemon will be running only on the server computer so there will be an open dos window

The client will run with out an open dos widow
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> No need to include Jini jars files. Can be launched from the run box

So were is it going to get the jini classes from?

0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Here's a startup bat file that we distribute with one of our products.

rem @echo off

rem Slurp the command line arguments.  This loop allows for an unlimited number of
rem agruments (up to the command line limit, anyway).

set JOSI_CMD_LINE_ARGS=

:setupArgs
if %1a==a goto doneArgs
set JOSI_CMD_LINE_ARGS=%JOSI_CMD_LINE_ARGS% %1
shift
goto setupArgs

:doneArgs
rem The doneArgs label is here just to provide a place for the argument list loop
rem to break out to.

rem find JOSI_HOME
if not "%JOSI_HOME%"=="" goto checkJava

rem check for josi in Program Files on system drive
if not exist "%SystemDrive%\Program Files\josi" goto checkSystemDrive
set JOSI_HOME=%SystemDrive%\Program Files\josi
goto checkJava

:checkSystemDrive
rem check for josi in root directory of system drive
if not exist "%SystemDrive%\josi" goto noJosiHome
set JOSI_HOME=%SystemDrive%\josi
goto checkJava

:noJosiHome
echo JOSI_HOME is not set and josi could not be located. Please set JOSI_HOME.
goto end

:checkJava
if "%JAVACMD%" == "" set JAVACMD=java

set LOCALCLASSPATH="%CLASSPATH%"
for %%i in ("%JOSI_HOME%\lib\*.jar") do call "%JOSI_HOME%\bin\lcp.bat" "%%i"

if "%JAVA_HOME%" == "" goto noJavaHome
if exist "%JAVA_HOME%\lib\tools.jar" call "%JOSI_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\tools.jar"
if exist "%JAVA_HOME%\lib\classes.zip" call "%JOSI_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\classes.zip"
goto checkJikes

:noJavaHome
echo.
echo Warning: JAVA_HOME environment variable is not set.
echo   If build fails because sun.* classes could not be found
echo   you will need to set the JAVA_HOME environment variable
echo   to the installation directory of java.
echo.

:checkJikes
if not "%JIKESPATH%" == "" goto runJosiWithJikes

:runJosi
%JAVACMD% -classpath %LOCALCLASSPATH% -Djosi.home="%JOSI_HOME%" %JOSI_OPTS% JosiScanLite %JOSI_CMD_LINE_ARGS%
goto end

:runJosiWithJikes
%JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%JOSI_HOME%" -Djikes.class.path=%JIKESPATH% %JOSI_OPTS% JosiScanLite %JOSI_CMD_LINE_ARGS%

:end
set LOCALCLASSPATH=
set JOSI_CMD_LINE_ARGS=

0
 
LVL 92

Expert Comment

by:objects
Comment Utility
I think it depends alot on whether your looking for an installation method for the general public, or whether it's a particular user or set of users.
More more you know about the target environment, the less assumptions you have to make.

I mentioned using an executable jar above, but forgot to mention that this is only supported for 1.2+.
For 1.1 you'll have to startup using the 'traditional' means, ie. specifying the main class explicitly.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Expert Comment

by:prem_kumar79
Comment Utility
Jini jars will be in jre.
0
 

Expert Comment

by:prem_kumar79
Comment Utility
Sorry u have to include the Jini jars files in ur application
0
 
LVL 1

Author Comment

by:WinDude
Comment Utility
The jar file gives me an error that it can't find 'main' method in my main-class listed in the manifest file.  It clearly has a main method that I can invoke when it is not in the jar file.

Any ideas?
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Are your classes in packages?
And if so did you maintain your directory structure in your jar?
If class A is in package P then A.class needs to be in the P directory in your jar.

Can you post the error message, and the manifest?
0
 
LVL 1

Author Comment

by:WinDude
Comment Utility
I got the jar figured out and it runs... almost.  There is a problem with the policy file.  If the policy file is outside the jar then the app runs, but I would like the policy file to be inside the jar.

The error message with the policy file inside the jar is:
access denied (net.jini.discovery.DiscoveryPermission *)

0
 
LVL 1

Author Comment

by:WinDude
Comment Utility
ok, I moved the policy file to the http server and that part works now.

The only thing left is launching the application.  I would like to do it without leaving open a command window/dos window and only have the application window present.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Start it using javaw.exe, instead of java.exe.
0
 
LVL 1

Author Comment

by:WinDude
Comment Utility
after much trial and error I was finally able to get this to work.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now