4 Replies Latest reply on Apr 13, 2012 8:18 PM by EJP

    Run a Java Program


      I created a java program using eclipse.. How can I package it and run the program in windows or Unix?

        • 1. Re: Run a Java Program
          Put it into a JAR file with a Manifest which has a Main-Class entry with the appopriate value. Then you can run it with java -jar myjar.jar.
          1 person found this helpful
          • 2. Re: Run a Java Program
            Right click the project in the Package Explorer. In the popup menu go Run as->Run Configuration. Click the new configuration button. In the Name box pick a name for your configuration. Make sure the right project is shown in the project field. If not click the browse button and select the right project. Make sure the right main class is listed in the main class field. If not click the browse button and select the correct class. Click apply. Click close. In the popup menu click Export. Double click the Java folder so it drops down. Double click Runnable JAR file. In the Launch Configuration drop down box make sure the right project and main class is shown in this form: Configuration name-main class name. Click the browse button to set the location you are saving the Jar file to. Click finish. Now find the JAR file and double click it to start the program.
            • 3. Re: Run a Java Program
              Another alternative is to manage the project with Maven, which makes building & deploying JARs, WARs, etc. a breeze.
              • 4. Re: Run a Java Program
                The OP is going to learn precisely nothing from being spoonfed like that. Don't do that. We want to give people fishing rods, not fish.