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.

Results 1 to 6 of 6

Thread: help with java apps.

  1. #1
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default help with java apps.

    How can I run a Java App. on another computer that doesn't have the java JDK?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: help with java apps.

    You don't need the JDK to run a Java program, just the JRE/JVM.

  3. #3
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: help with java apps.

    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.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: help with java apps.

    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>

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help with java apps.

    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).

  6. #6
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: help with java apps.

    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):
    Manifest-Version: 1.0
    Created-By: 1.6.0_14 (Sun Microsystems Inc.)
    Class-Path: SX.jar
    Main-Class: ExcelChart
    A few notes about the manifest:
    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.

Similar Threads

  1. How to start writing Java Apps for Cell Phones?
    By Jchang504 in forum Java ME (Mobile Edition)
    Replies: 7
    Last Post: January 10th, 2011, 05:11 AM
  2. Bluetooth for commercial java apps
    By alex100 in forum Java Networking
    Replies: 0
    Last Post: March 6th, 2010, 06:28 PM