I have a Raspberry Pi running Java 1.8.0 and a file called test.jar. When I run the code and then stop the program with Ctrl+Z the Shutdown hook does not run but when I run the code on windows and stop it, the shutdown hook will work.
How can I fix this, Thanks
public class Test
{
public static void main(String[] args)
{
Runtime.getRuntime().addShutdownHook(new Thread() //Add shutdown code
{
public void run()
{
System.out.println("Shutdown");
}
});
while(true) { }
}
}