1

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:

  1. 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 !!

Paul
  • 11
  • 3

1 Answers1

1

Use the macOS open command to run an application:

open -a Console

You can't find Console using the ls command in /Applications because Finder is actually showing the contents of /Applications merged with /System/Applications. The path to Console is actually:

/System/Applications/Utilities/Console.app/Contents/MacOS/Console

This split was introduced in macOS Catalina.

Note: System.console() is something else entirely, it isn't available in Eclipse.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thanks so much !! Any idea where might I have found this documented ? – Paul Dec 08 '21 at 19:14
  • Sorry, I don't know where this is documented, I just remember seeing it in a "whats new" article. Everything that should not be changed was moved to the read only `/System` file system. Finder often doesn't show exactly what is in the file system. Command line utilities such as `ls` are more reliable for that. – greg-449 Dec 13 '21 at 11:45