0

I am playing around with some GIT commands in terminal, but I want to write a java program to automate the process.Please note I am not writing a program straight into a terminal. I am writing it in eclipse. This following code works on windows, but not MAC. How should I change it to run on MAC?

import java.io.*;


public class NewClass {



public static void main(String[] args) {  
    try {  
        Process p = Runtime.getRuntime().exec("GIT");  
        BufferedReader in = new BufferedReader(  
                            new InputStreamReader(p.getInputStream()));  
        String line = null;  
        while ((line = in.readLine()) != null) {  
            System.out.println(line);  
        }  
    } catch (IOException e) {  
        e.printStackTrace();  
    }  
}  

}

2

2 Answers 2

1

"GIT" should be "git" for case sensitive systems like Mac OS. Note that without arguments, this will only give you a listing of the git syntax.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you, but that wasn't the issue, as I have tried different commands" This works perfectly on Windows, so the command should't be the problem.
It works on Windows because commands are not case sensitive on Windows. On Windows, an upper case "GIT" command means the same thing as a lower case "git" command. On Mac OS, they mean different things.
I have been using different commands, just typed this with a mistake to shorten the code
I'm not sure OSX actually is case sensitive (any more?)... for example "GIT" actually does seem to work, though it still would not on linux.
@ChrisStratton valid point. OS X isn't really case insensitive, but it's also not strictly case sensitive like linux.
0

Please follow the basic steps outlined in this CS article from Princeton (How to run Java Program on a Mac)

1 Comment

Please not that I am not writing a program straight in to a terminal. It is done in Eclipse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.