I am trying to update a 200,000 line program written in Java/Eclipse in 2009.
I imported it to the latest Eclipse/Java, and there are several problems:
the following line (which ran inn 2009) generates an error message
try { consoleProcess = Runtime.getRuntime().exec("/Applications/Utilities/Console.app/Contents/MacOS/Console"); } catch (Exception err) { err.printStackTrace(); }
The error message is "java.io.IOException: Cannot run program "/Applications/Utilities/Console.app/Contents/MacOS/Console": error=2, No such file or directory at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1142)"
However, the file is definitely there, it shows up in the finder (although not in an "ls" command from a terminal window, which I'd also like to get input on.) and I can click on it and run it. I also cannot run BBEdit this way : I can however run open/run XQuartz using similar code.
I started trying to write around this problem by trying to open a console with the following code, which however produces the error message that "The console is NULL"
import java.io.Console;
Console console = System.console();
if(console == null) {
System.out.println("The console is NULL");
}
else
{
String ch=console.readLine();
}
Thanks so much !!
Use the macOS
opencommand to run an application:You can't find Console using the
lscommand in/Applicationsbecause Finder is actually showing the contents of/Applicationsmerged with/System/Applications. The path to Console is actually:This split was introduced in macOS Catalina.
Note:
System.console()is something else entirely, it isn't available in Eclipse.