Running java applications on any platform

R

rob hadow

If a java application is successfully compiled to a .class file, what else
is needed to run the application on another platform (assuming the platform
has a JVM)?

To put it simply, I compile my application, put the .class file on a CD Rom.
Load the .class file onto another PC that does not have a SDK. What else do
I need to do?

I don't want to have to turn the application into an applet.

Many thanks for any help.

Rob Hadow

PS Now that I have just passed the SCJP1.2 I want to gain some practical
experience, as I have none!
 
M

Michael Rauscher

Hi Rob,

rob said:
If a java application is successfully compiled to a .class file, what else
is needed to run the application on another platform (assuming the platform
has a JVM)?

You need to start it ;-)

Of course you need the libraries that your application was compiled against.
To put it simply, I compile my application, put the .class file on a CD Rom.
Load the .class file onto another PC that does not have a SDK. What else do
I need to do?

Install the JRE.

As I assume that your application doesn't consist of only one class file
it would be nice to put them together in a jar.

You can make the jar "executable" by specifying the Main-Class attribute
in the jar's manifest. If you have additional libraries you can also
specify the Class-Path attribute. Such jars can then be executed via
java -jar myapp.jar and additionally under Windows by double clicking.
I don't want to have to turn the application into an applet.

If you are interested in web deployment, give Java Web-Start a try.

Bye
Michael
 
R

Roedy Green

If a java application is successfully compiled to a .class file, what else
is needed to run the application on another platform (assuming the platform
has a JVM)?

To put it simply, I compile my application, put the .class file on a CD Rom.
Load the .class file onto another PC that does not have a SDK. What else do
I need to do?

You tell the person they need to install a Java JRE and point them to
http://mindprod.com/jgloss/jre.html

Or you can include the JRE download on the cd, but you had best check
the licensing agreement to see if that is kosher.

Normally you bundle class files into a Jar, rather than sending them
into the world naked. See http://mindprod.com/jgloss/jar.html

see http://mindprod.com/jgloss/jumptojava.html
 
A

Andrew Thompson

If a java application is successfully compiled to a .class file, what else
is needed to run the application on another platform (assuming the platform
has a JVM)?

Michael and Roedy have given you the good stuff on
Jar'ing and JWS, so I will merely add a 'gotcha'

A Java programmer might code a string like..
StringTokenizer st = new String(s , "\n\r");

The problem is that "\n\r" is presuming a
particular EOL delimiter. I mention it briefly here..
<http://www.physci.org/codes/javafaq.jsp#xplatform>

You will find a link to a document that will
probably give you good Google fodder.

HTH
 
A

Andrew Thompson

A Java programmer might code a string like..
StringTokenizer st = new String(s , "\n\r");

.....errrrr. A Java programmer might make stupid typos..
I will try that again.
......
A Java programmer might code a string tokenizer like..
StringTokenizer st = new StringTokenizer(s , "\n\r");
 
A

Andy Fish

don't forget the old java addage "write once, test anywhere"

it's possible to write very portable java apps, but it's possible to write
non-portable ones too
 
A

Andrew Thompson

don't forget the old java addage "write once, test anywhere"

....errr. I have heard.
'Write once, run anywhere', and the piss-take,
'Write once, test everywhere'*, but not that variant..

* An important thing to keep in mind when writing code..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top