1

I am trying to build a project in Eclipse (Neon.2 Release (4.6.2)) and am trying to use Java and C. I'm not asking how to code in either language, but I'm not sure how to call a C main function passing it a param from a Java class or function. I know projects are made from multiple languages but I'm not sure how it's done and I haven't found a very solid answer from Google.

Thanks in advance.

CS2020
  • 153
  • 1
  • 10
  • Sorry, I'm a little confused here. Why are you talking about a C main function? Is your question about calling any C function from Java and it just happens that the function you're trying to call is named `main`? Or do you have a standalone app written in C and want to invoke it from Java? – Anatoli P Jul 14 '17 at 23:06
  • I have an app that's basically a single function that needs to be written in C rather than Java. I wrote the function and call it from a `main` C function. – CS2020 Jul 15 '17 at 03:09
  • You can call, from Java, the C `main` function or that single function you call from `main`. To do this you can use JNI, see https://stackoverflow.com/questions/5963266/call-c-function-from-java. Alternatively, you can build your C app and then invoke it from Java as an external process, see https://stackoverflow.com/questions/5604698/java-programming-call-an-exe-from-java-and-passing-parameters. – Anatoli P Jul 18 '17 at 00:48

0 Answers0