3
package com.company;

public class Main {

    public static void main(String[] args) {
        int count = 0;
        do {
            count = count + 1;

            if (count == 500000000) {
                break;
            }

            System.out.print(count);
            System.out.print("\n");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
            }
        }while(true);
    }
}

Simply want this to run in the console from jar file, not in the background

Andreas
  • 154,647
  • 11
  • 152
  • 247

1 Answers1

1

1) Create a text file named Main.mf which contains following two lines:

Manifest-Version: 1.0

Main-Class: Main

2)Then create the archive by typing:

     jar cmf Main.mf Main.jar Main.class Main.java

3) Then run it by using

     java -jar Main.jar
Sandunka Mihiran
  • 556
  • 4
  • 19