How can I run a Java App. on another computer that doesn't have the java JDK?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How can I run a Java App. on another computer that doesn't have the java JDK?
You don't need the JDK to run a Java program, just the JRE/JVM.
Well I made a simple chat program to test with a friend of mine. I gave it the class files to him and had him type "java classMainName" and the command prompt flashed a bunch of words and closed.
Have the friend open a command prompt and enter: java -version
If the OS does not find the command it will say so with a message like this:
D:\JavaDevelopment\NormsTools>java -version
'java' is not recognized as an internal or external command, <<<<<<<<<<<<<<<<<<<<<< THIS
operable program or batch file.
D:\JavaDevelopment\NormsTools>
You could alternatively package your app as a runnable Jar. This way there would be no need for command line operations...just double click the jar and it should run (unless the java versions aren't compatible -eg you compiled for a min version java 6 and your friend has java 5 or older).
There are two options.
1) if you have a java app instead of a java application, you can embedd it into a webpage and find a free host or something. It just takes a little bit of html to run a class file.
2) you can do what copeg suggested and make a jar. You can do this manually without much of a problem. Put all of the .class files in a zip file. Create a folder named META-INF. Then create a file inside that folder named MANIFEST.MF. Include the following in the manifest (edit with notepad or something):
A few notes about the manifest:Manifest-Version: 1.0
Created-By: 1.6.0_14 (Sun Microsystems Inc.)
Class-Path: SX.jar
Main-Class: ExcelChart
1) Class-Path is only nessisary if you are using external libraries. These paths must be the EXACT path of the external library. If the external library will be in the same folder as the exectuable, you can just put the name as it is taken as a relative path.
2) Main-Class is the main class file of your program (the file that contains the main method). Do not include the extension for this.
3) An extra blank line at the end is required. Dont know why, it just is.
Now put the META-INF folder in your zip file. Now rename the zip file and change the extension from .zip to .jar. And presto, you have an executable.