aspose file tools*
The moose likes Beginning Java and the fly likes Running a program in other computer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running a program in other computer" Watch "Running a program in other computer" New topic
Author

Running a program in other computer

william brown
Greenhorn

Joined: Jul 19, 2005
Posts: 16
Hi,

This might be a very simple question. I have developed a JAVA program and I want to run it on other computer with different Operating system (UNIX). This means that I dont have to compile the program again.

What should I do? What do the other computer must have in order to be able to run my program?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

If it's a standalong application, it just has to have Java installed, and it has to have your *.class files. That's about it! If it's a servlet or something like that, then it needs an appropriate container to run in, as well, of course.


[Jess in Action][AskingGoodQuestions]
william brown
Greenhorn

Joined: Jul 19, 2005
Posts: 16
Yes.. it is a standalone program.. what should i do with that *.class files. How do I run it..
Mahesh x Bogadi
Ranch Hand

Joined: Jul 06, 2004
Posts: 51
first check the CLASSPATH and PATH variable.

let you want to run program test, u have test.class...

go to the directory where test.class is there
give the command

>java test
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Ernest Friedman-Hill:
If it's a standalong application, it just has to have Java installed, and it has to have your *.class files. That's about it! If it's a servlet or something like that, then it needs an appropriate container to run in, as well, of course.


More speicifically, the other machine needs the Java Runtime Environment (JRE), but not the complete Java Development Kit (JDK).

Originally posted by Ernest Friedman-Hill:
Yes.. it is a standalone program.. what should i do with that *.class files. How do I run it..


I'm not sure what environment you are using to develop the program in. If you are using a text editor and the command line, running the program on a Unix machine is the same as running it under Windows: type "java ClassName". Of course, this means that you need to set the PATH variable to the JRE installation and change to the directory that contains your *.class files.

If this doesn't completely answer your question, please describe how you run it on your development machine. I'll be glad to describe the differences you will encounter on a Unix machine.

Layne


Java API Documentation
The Java Tutorial
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
I usually create a jar file, since it's not too nice to ship around a bunch of class files. And, if you don't have a bunch of class files, then you are not using the OO aspect of Java, and shame on you!

Don't forget (like I did ;-) that the SDK you build with better be less than or equal in version to the one on Unix. I built with 1.4 and the one on Unix was 1.3. I knew right away when I saw that methods didn't exist (I think it was String replace or something). Anyway, if you jar up your code, you should be able to run it by doing a "java -jar MyProggy.jar" on both systems. The jar file saves you from messing around with longer command lines too, due to packages (you ARE using a package, I hope).

--Dale--
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Running a program in other computer