mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.26k stars 242 forks source link

Terminal On Windows #546

Closed BeanVortex closed 3 years ago

BeanVortex commented 3 years ago

Hi Code works fine on Linux but on windows it can't find Terminal. Error:

Exception in thread "main" java.io.IOException: To start java on Windows, use javaw! (see https://github.com/mabe02/lanterna/issues/335 ) at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createWindowsTerminal(DefaultTerminalFactory.java:457) at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createHeadlessTerminal(DefaultTerminalFactory.java:140) at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createTerminal(DefaultTerminalFactory.java:113) at TypeConsole.App.main(App.java:25) Caused by: java.io.IOException: Cannot run program "stty.exe": CreateProcess error=2, The system cannot find the file specified at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.exec(UnixLikeTTYTerminal.java:158) at com.googlecode.lanterna.terminal.ansi.CygwinTerminal.runSTTYCommand(CygwinTerminal.java:94) at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.saveTerminalSettings(UnixLikeTTYTerminal.java:113) at com.googlecode.lanterna.terminal.ansi.UnixLikeTerminal.acquire(UnixLikeTerminal.java:86) at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.realAcquire(UnixLikeTTYTerminal.java:86) at com.googlecode.lanterna.terminal.ansi.UnixLikeTTYTerminal.<init>(UnixLikeTTYTerminal.java:77) at com.googlecode.lanterna.terminal.ansi.CygwinTerminal.<init>(CygwinTerminal.java:63) at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createCygwinTerminal(DefaultTerminalFactory.java:463) at com.googlecode.lanterna.terminal.DefaultTerminalFactory.createWindowsTerminal(DefaultTerminalFactory.java:455) ... 3 more Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.base/java.lang.ProcessImpl.create(Native Method) at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:483) at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:158) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1109) ... 13 more

By using javaw it opens a SwingTerminalFrame window which many functionalities are not working

avl42 commented 3 years ago

Terminal applications, such as what Lanterna helps one to create, aren't natively "at home" in Windows...

One solution are SwingTerminal apps (with javaw.exe). You might want to help add the missing bits to it.

Another would be installing Cygwin and use Lanterna in Cygwin terminals.

Another would be the WindowsTerminal (using JNA, iirc), which would need some active developers/testers to get into shape.

For a starter, look at the tree "native-integration" and try to get that into your build environment.

(I can't help much there - my own computers are a "Window"-less environment.)

BeanVortex commented 3 years ago

Terminal applications, such as what Lanterna helps one to create, aren't natively "at home" in Windows... One solution are SwingTerminal apps (with javaw.exe). You might want to help add the missing bits to it. Another would be installing Cygwin and use Lanterna in Cygwin terminals. Another would be the WindowsTerminal (using JNA, iirc), which would need some active developers/testers to get into shape. For a starter, look at the tree "native-integration" and try to get that into your build environment. (I can't help much there - my own computers are a "Window"-less environment.)

OK. thanks

rednoah commented 3 years ago

@DarkDeveloper-Plant Have you tried 3.2.0-alpha1 yet? I've been using the JNA for a year and it works well for my use cases: https://github.com/mabe02/lanterna/issues/422

rednoah commented 3 years ago

The JNA implementation is production-ready as far as I can say, and definitely preferable to the To start java on Windows, use javaw! error message. I'd rather get a "can't load JNA" error message, and then go ahead and add JNA to the classpath.