Suggestions needed: Effective Java to C source code converter

27,295

Solution 1

This is possible, but extremely difficult - for starters, you would need to integrate a garbage collector with your C source. There are a few projects that attempt this, e.g. Toba, but they're unreliable and no longer maintained. Usually you'll find somebody attempting something like this in their Master's thesis, after which it is quickly abandoned.

If you're doing this to try to speed up your program, then don't - Java is already pretty fast compared to natively compiled code (although it tends to use quite a bit more memory), and your translated C code is not going to be able to take full advantage of the C language.

Solution 2

Universal-transpiler can translate Java programs into several other programming languages, including C. This software is still experimental, but it is already able to translate a subset of Java into C and several other languages.

For example, this is one possible input in Java:

public static int add(int a, int b){
    int i = 0;
    System.out.println("hello");
    return a + b;
}

...and this is the translator's output in C:

int add(int a,int b){
    int i=0;
    printf("%s\n","hello");
    return a+b;
}
Share:
27,295
Rookie
Author by

Rookie

Updated on July 09, 2022

Comments

  • Rookie
    Rookie almost 2 years

    I googled a bit but could not find any good Java to C source code converter.

    My question is:

    1. Is this possible ?

    2. Are there any reliable Java to C src converter you can think of which I can have a look at?