1

I'm trying to deploy a small console-based program I've been working on as an executable Jar file. I made sure the Manifest file specified the Main-Class, so it should run automatically. There's no GUI, it just uses the console. Good old Scanner and System.out.println sort of stuff. When I double-click the Jar file, the console flashes but closes immediately.

To be sure it wasn't something wrong with the program itself, I retried with the simplest program I could think of. I'll include code below, but it's nothing special. I included a Scanner.next() call to make sure the console should stay open until I give it input, but it's still not running.

I also tried launching the Jar from the command line. java -jar Deploy.jar works just fine. But I want to be able to run it with a double-click, without having to open the command line or an IDE. Am I missing something?

Deploy.java

import java.util.Scanner;
public class Deploy {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("Hello World!");
        s.next();
        s.close();
    }
}

MANIFEST.MF

Manifest-Version: 1.0
Main-Class: Deploy

(Yes, I've got carriage returns at the end of my Manifest)

JCaredig
  • 11
  • 1
  • This feels like something that should go in the Manifest file, but I'm not seeing anything. Hopefully someone else has the answer. – markspace Sep 23 '20 at 15:16
  • Have you tried invoking it from an existing (currently open) command line (via `java -jar myJar.jar`) to see if there's anything wrong with the program? – BeUndead Sep 23 '20 at 15:19
  • Yeah, I've tried running it from the command line and it runs just fine. :-/ – JCaredig Sep 24 '20 at 12:56

0 Answers0