O
O
Oleg Komenda2018-03-27 12:41:21
Java
Oleg Komenda, 2018-03-27 12:41:21

The jar does not have a console. What to do?

Wrote the first code. Did 'Build Artifacts', got .jar file. I open it, but the console is not visible. OS windows 10.
Here is the code, maybe something is wrong

package com.company;

import java.util.Scanner;
import java.lang.String;

public class Main {

    public static void main(String[] args) {
       System.out.print("Hello world!");
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2018-03-27
@jamakasi666

You need to launch it not by double clicking, but through the console with the command "java -jar name.jar" or by default associate java.exe with jar files.
Explanation:
In windows in jre there are 2 exe runtime files
java.exe - by default it's like console but also easy with
javaw.exe graphics - the console will be hidden BUT the application will work, the graphics will be displayed as expected.
UPD if there is no manifest or the entry point is not specified in it, then it will be like this "java -jar name.jar package.main_class"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question