0

I'm writing a text/code editing program for my own use in Java/Swing, and was wondering how I would go about setting up a built-in C compiler inside it. I would likely use GCC or TCC as the compiler. Anyway, my question is- how would I actually implement the compiler? Would I use a library that gives Java access to command line commands? Are there such libraries and if so, which is the best/easiest to use?

Thanks.

2 Answers 2

2

Accessing command line is the easiest way. Try something like this:

Process myProc = Runtime.getRuntime().exec(command);

Where command is some string you want to pass to the command line.

After that you can redirect output / input of that process to the some java buffers to have the full control.

myProc.getInputStream();
myProc.getOutputStream();
Sign up to request clarification or add additional context in comments.

Comments

2

Typically IDE/Editor's don't implement the compilers. They will just execute the commands and pass the filename as argument (along with other necessary files). They also pipe/stream the output to a separate window/pane in the editor. So you need to integrate the compiler somehow not implement one. You can execute the commands in java using Runtime class. Start here.

Comments

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.