Does anyone know wether i can convert a Java written program to C?
Thank You
For : short answer — it is possible in principle, but not a simple source-to-source conversion and rarely worth the effort for anything nontrivial. Java relies on a managed runtime (garbage collection, a rich standard library, reflection, dynamic classloading, threads and well-defined object semantics). Reproducing all of that correctly in plain C is time consuming and error prone.
As hinted, there are better practical routes than trying to translate every Java file to C. Common choices today are:
If a manual port is chosen, follow a checklist:
Small example of mapping a trivial class to C:
/* Java
class Counter { private int c; public void inc(){c++;} public int get(){return c;} }
*/
/* C */
typedef struct { int c; } Counter;
void Counter_init(Counter *s) { s->c = 0; }
void Counter_inc(Counter *s) { s->c++; }
int Counter_get(Counter *s) { return s->c; } Recommendation: profile first. If the goal is performance or a standalone binary, prototype with an AOT/native-image approach or isolate and rewrite the real hotspots in C. Full automatic conversion is uncommon and creates long-term maintenance headaches.
Jump to Post— hollystyles 113There is some sotware called Toba here:
There is some sotware called Toba here:
There is some sotware called Toba here:
But I guess there wasn't much call for it, as it isn't supported and only works for Java 1.1.
If you are looking to compile Java to native code you can do that directly without the C step. Which also can be found via the above link or just Google a bit.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.