2

I would like to use the JCurses Library with IntelliJ IDE but I have the following error message : "Error opening terminal: unknown."

My code :

import jcurses.system.*;
// Test Jcurses
Toolkit.init();

My Config :

  • VM Debian 8.7 64-bits with IntelliJ 2016.3.3 and JAVA Open JDK 64-bits 1.8
  • Lib directory with jcurses.jar and libcurses64.so

I don't find any documentation about the good way to do it.

Does anyone have an idea ?

ManWithNoName
  • 381
  • 1
  • 6
  • 20
  • Probably because IntelliJ doesn't have a full terminal emulator. In your run settings, can you define the environment variable `TERM=dumb`? Also, can you make sure you've installed ncurses (`sudo apt-install ncurses` I believe). You need the termcap database I eould imagine. – Qix - MONICA WAS MISTREATED Feb 15 '17 at 21:22
  • By adding the environment variable TERM=dumb, the error message disappears !!! Thanks – ManWithNoName Feb 15 '17 at 21:34
  • I have tried then to add this line : `Toolkit.printString("hello", 0, 0, new CharColor(CharColor.BLUE, CharColor.BLACK));` but it displays a black line without my text "Hello". – ManWithNoName Feb 15 '17 at 21:35
  • Yep, as expected. The intellij console is not a real console - the best you're going to get is some black output, or maybe red output if you print to standard error. :) – Qix - MONICA WAS MISTREATED Feb 15 '17 at 23:14

1 Answers1

3

IntelliJ IDEA console tool window is not a real terminal.

There is a feature request to allow running in the external console. See also another related request.

At the moment you can configure the External Tool which will spawn a console and run your app there, but IDE integration will be not available for this console (however, you can still use Remote Debug).

Or you can use the Terminal tool window to run your app there manually. It would be handy to pack your app into an executable jar with all the dependencies. Then you will be able to run it like java -jar myapp.jar in the Terminal tool window or in the external terminal window.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 1
    When I run `java -jar myapp.jar`, I obtain the following error message : Exception in thread "main" java.lang.ExceptionInInitializerErrorCaused by: java.lang.NullPointerException at jcurses.system.Toolkit.getLibraryPath(Toolkit.java:111) at jcurses.system.Toolkit.(Toolkit.java:37) – ManWithNoName Feb 15 '17 at 22:14
  • JCurses uses [some magic](http://pastebin.com/4B46xB1s) to find where the native libraries are located, so it may not work if you are trying to load it from the same jar as your main app. You can create an artifact with [linked dependencies](http://stackoverflow.com/a/42200519/104891) instead. `jcurses.jar` and `.so` files should reside next to your app jar to work. – CrazyCoder Feb 15 '17 at 22:30