Solved

Launching Java Application...

Posted on 2001-07-20
15
435 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 62
Arrays.asList  VS  ArrayList 4 71
hibernate jars 4 45
running on tomcat not jboss eap 7.0 3 17
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilationā€¦
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

789 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