Call Java class (.JAR) using C++ (.EXE)?

Asked

Viewed 450 times

1

I have a Java application (SYSTEM.JAR) with the system input class ... Ok?

To make it more transparent to the end user, I would like to create a compiled . EXE in C++ that just calls the Java class.

It is possible ?

Which C++ compiler suggested? (the smallest possible, given the complexity)

Thank you.

Lucius

  • 1

    What real advantage do you expect to have with this? It’s not going to change anything. If you just want it to call the class automatically you can register the extension to call Java yourself or make a file batch to call. I can’t imagine how creating an executable just to call Java is better than this.

  • I share @bigown’s opinion, that’s not practical at all. Another thing, there is no way you can call a java class in another language, the most you could do is call the file. jar and let the JVM load its input class.

  • I understand the point of view of each of the answers. But I would still like to do a test, becoming transparent to the user the technology used. What’s up? Someone knows how to do it?

1 answer

2

As stated in the comments, this is not practical and does not make as much sense even to the end user. What I can recommend is to create an installer that extracts files from your program in a folder and create a shortcut to ". jar" on the Desktop. Or if you yourself are going to integrate the system into each machine it is used, simply create the Desktop shortcut.

But in answer to the original questions...

"Is it possible?" Yes.

"What is the suggested compiler?" Mingw.

Example:

#include <cstdlib>
int main(){
    std::system("java -jar 'caminho-do-programa/Sistema.jar'");
    return 0;
}

This will start the . jar application and will close your C mini-program++.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.