Search code examples
javamacosterminalgedit

Problems opening a java file using gedit on terminal


I'm using the terminal to test all my Java code. I have a Mac. When I compile for example:

->javac MyJava.java (it compiles perfectly)

->java MyJava (it works perfectly)

But the problem is when I'm trying to edit that java file using gedit, like this:

->gedit *.java

it displays an error:

->(gedit:12827): Gtk-WARNING **: cannot open display:

What would be the cause? Also I already have installed gedit on my Mac, but still it is giving the same problem.

Regards!


Solution

  • You're trying to launch an editor (gedit) that requires Xwindows. Download and install a Xserver (like XQuartz) or use a terminal based editor like vim, or use a native Mac editor.