re: Is there a way to make the computer's native console (if there is one) appear in Java? VIEW POST


What you can do is create a runnable JAR file. For that, you need to include a file MANIFEST.MF in the META-INF subfolder of you JAR file. IDEs like Eclipse or IntelliJ support you in doing that.

That manifest needs to reference the main class name. It may look similar to this:

Manifest-Version: 1.0
Main-Class: programpkg.Program
Class-Path: .

Here's what my example Java class looks like. It looks a bit different than yours, but it reads a line from the console:

package programpkg;

import java.util.Scanner;

public class Program {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      System.out.print("Please enter a line: ");
      String line = sc.nextLine();

Depending on the operating system and JRE, you may be able to double click on the JAR file to start it.
In Windows 10, and if you use OpenJDK, one way to start it is creating a batch script start.bat like with these contents, place it in the same folder as your jar:

java -jar Program.jar

and then start it with double click


I heard manifest.txt works too? Is this true? Thanks again for your help!


Sorry, there was a typo in my original comment that I corrected now. The correct name in the JAR file is MANIFEST.MF.

I guess what you are referring to is that you can specify a MANIFEST.txt as input to the jar tool, as documented in the Oracle docs. That's correct. But I think that inside the JAR file itself, the file name must be MANIFEST.MF.

code of conduct - report abuse