Link to home
Start Free TrialLog in
Avatar of WinDude
WinDude

asked on

Launching Java Application...

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?
Avatar of rrz
rrz
Flag of United States of America image

Have you condidered Java web start?
http://java.sun.com/products/javawebstart/index.html
Avatar of WinDude
WinDude

ASKER

Yes I have.  I guess I'm asking how to do it manually.
> 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.
ASKER CERTIFIED SOLUTION
Avatar of prem_kumar79
prem_kumar79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> 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?

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=

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.
Jini jars will be in jre.
Sorry u have to include the Jini jars files in ur application
Avatar of WinDude

ASKER

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?
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?
Avatar of WinDude

ASKER

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 *)

Avatar of WinDude

ASKER

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.
Start it using javaw.exe, instead of java.exe.
Avatar of WinDude

ASKER

after much trial and error I was finally able to get this to work.