• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I run this program?

 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to play around with the build once run anywhere ideal Java has. I created a simple app on a Win box and I moved it over to my Linux Server. How can I run it from there? What are the proper commands?
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how did you build it on your windows box? And how did you launch it?
If you created a batch-file to launch it, you can do the same kind of thing on Linux. you'll create a shell script that calls java.exe, passing it the classpath for your class files, and the main class to use as an entry point. The .class files are bytecode so they run exactly the same on both platforms.
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a JRE on your Linux server, right? Type
java YourClassFile
same as you do in a Win DOS window (unless it's an applet)
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob, it's nothing special. Just a simple HelloWorld deal to see if it really just carries over.
Marilyn, I downloaded the SDK last night and installed it. Do I need to edit the environment variable like I did in Windows?
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,
I think there is a path-type environment variable like there is in unix, isn't there? SO you can put the name of the java executable in the path so it can find it.
At a command prompt you can type
java -version
and if you get output from the java program, you know it's installed. Then you can just cd to the directory your HelloWorld.class file is and type
java HelloWorld just like on the PC.
I'm not sure how to add java.exe to your path on Unix, but you can allways use the full path name to it...for example
/usr/javahome/bin/java HelloWorld
assuming that's where your java binary is of course.
 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that's what I was thinking. Now I just need to find where it is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic