/*
 * Copyright 2020 See AUTHORS file
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.badlogicgames.packrtestapp;

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

/**
 * Simple hello world application for testing the packr launcher.
 */
public class PackrAllTestApplication {
	 /**
	  * Main CLI entrance.
	  *
	  * @param args ignored
	  *
	  * @throws IOException if an IO error occurs
	  */
	 public static void main (String[] args) throws IOException, InterruptedException {
		  JFrame myFrame = new JFrame("Hello");
		  myFrame.getContentPane().add(new JLabel("Hello world!"));
		  myFrame.pack();
		  myFrame.setLocationRelativeTo(null);
		  myFrame.setVisible(false);
		  myFrame.dispose();

		  System.out.println("Hello world!");
		  System.out.println("Running from java.version=" + System.getProperty("java.version"));

		  Path javaExecutablePath = Paths.get(System.getProperty("java.home")).resolve("bin").resolve("java");
		  new ProcessBuilder(javaExecutablePath.toString(), "-version").inheritIO().start().waitFor();

		  Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
				System.out.println(
					"Received uncaught exception in thread.getName()=" + thread.getName() + ", Thread.currentThread().getName()=" + Thread.currentThread()
						.getName());
				throwable.printStackTrace(System.out);
		  });

		  try (Stream<String> lineStream = Files.lines(Paths.get("application-resources").resolve("fake-resource.txt"))) {
				lineStream.forEach(resourceLine -> System.out.println("Loaded resource line: " + resourceLine));
		  }

		  throw new RuntimeException(
			  "Testing uncaught exception handler. Thrown from the main thread, Thread.currentThread().getName()=" + Thread.currentThread().getName());
	 }
}

@@ -650,49 +650,20 @@
 java
-x.swing.JFrame;%0Aimport javax.swing.JLabel
+.awt.Toolkit
 ;%0Aim
@@ -1128,221 +1128,87 @@
 %09%09  
-JFrame myFrame = new JFrame(%22Hello%22);%0A%09%09  myFrame.getContentPane().add(new JLabel(%22Hello world!%22));%0A%09%09  myFrame.pack();%0A%09%09  myFrame.setLocationRelativeTo(null);%0A%09%09  myFrame.setVisible(false);%0A%09%09  myFrame.dispos
+System.out.println(%22ScreenSize=%22 + Toolkit.getDefaultToolkit().getScreenSiz
 e()
+)
 ;%0A%0A%09
@@ -1618,32 +1618,38 @@
 %7B%0A%09%09%09%09System.out
+%0A%09%09%09%09%09
 .println(%0A%09%09%09%09%09%22
@@ -1641,22 +1641,16 @@
 println(
-%0A%09%09%09%09%09
 %22Receive

Update TestApp to work in headless environments