3

I want to create some simple C code from Java, and I was wondering if there are some libraries that could help me. Sadly my google skills are not too good and my results are way off. ("C libraries for Java", "creating c code in java", etc).

My idea would be something like create C file and use method createMethod(name, argument, return, code) instead of having to just create a document and write strings like

return name(argument) {
   code
}

Nevertheless, I am little pessimistic and I think that most probably I will just have to create the C code by creating a document, and writing into it the c lines.

4
  • What advantage do you see in this approach that the code written in C doesn't give to you? Commented Feb 12, 2013 at 16:20
  • The advantage is that the C code is simple, but the way its generated is non-trivial, dynamic and automatic; therefore, I use Java in which I have more experience. If I used C, I would still like some kind of library help. @BalusC not sure if I expressed it right, the main project is Java and I need to create a few 100-200 lines of C code (in 2+ files) Commented Feb 12, 2013 at 17:00
  • 1
    See stackoverflow.com/questions/3455456/… Commented Feb 12, 2013 at 21:49
  • Interesting reading, and I do agree on the complexity of automatic code translation. I just figure maybe someone had written a library to write simple C files. So far I have not been able to find any, and inputting to a text files seems to be the nasty but easy way to do it. Commented Feb 13, 2013 at 9:12

1 Answer 1

1

One can use JCodeModel to create (Java) source code. You could create your own C targeted API mimicking the JCodeModel API. Maybe even extend the JCodeModel classes.

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

1 Comment

Sounds interesting, I will take a look. Seems like if I don't get an already done library, then maybe I could use this to create a C-library/API. I hope it wont be too hard to do.

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.