Solved

Launching Java Application...

Posted on 2001-07-20
15
433 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
ID: 6303741
Have you condidered Java web start?
http://java.sun.com/products/javawebstart/index.html
0
 
LVL 1

Author Comment

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

Expert Comment

by:objects
ID: 6304035
> 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
ID: 6304153
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
ID: 6304173
> 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
ID: 6304264
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
ID: 6304269
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:prem_kumar79
ID: 6306987
Jini jars will be in jre.
0
 

Expert Comment

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

Author Comment

by:WinDude
ID: 6318147
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
ID: 6320167
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
ID: 6322247
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
ID: 6322780
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
ID: 6324614
Start it using javaw.exe, instead of java.exe.
0
 
LVL 1

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 68
couple of eclipse 5 19
difference of if loops 23 40
use lov values 2 29
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

911 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

16 Experts available now in Live!

Get 1:1 Help Now