aspose file tools*
The moose likes Beginning Java and the fly likes How can I run this program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How can I run this program?" Watch "How can I run this program?" New topic
Author

How can I run this program?

Chris Stewart
Ranch Hand

Joined: Sep 29, 2001
Posts: 124
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

Joined: Jan 07, 2002
Posts: 2205
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.


Rob
SCJP 1.4
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
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)


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Chris Stewart
Ranch Hand

Joined: Sep 29, 2001
Posts: 124
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

Joined: Jan 07, 2002
Posts: 2205
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

Joined: Sep 29, 2001
Posts: 124
Yeah, that's what I was thinking. Now I just need to find where it is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I run this program?