Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running a program in other computer

 
william brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
william brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. it is a standalone program.. what should i do with that *.class files. How do I run it..
 
Mahesh x Bogadi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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--
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic