4 Replies Latest reply: Apr 13, 2012 3:18 PM by EJP RSS

    Run a Java Program

    926272
      Hi,

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

      Thanks
        • 1. Re: Run a Java Program
          EJP
          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.
          • 2. Re: Run a Java Program
            923889
            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
              aksarben
              Another alternative is to manage the project with Maven, which makes building & deploying JARs, WARs, etc. a breeze.
              • 4. Re: Run a Java Program
                EJP
                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.