Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Launching Java Application...

Posted on 2001-07-20
15
Medium Priority
?
440 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 28

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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

Accepted Solution

by:
prem_kumar79 earned 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

670 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