Convert Java jar file in to cpp

半世苍凉 提交于 2020-01-11 13:10:07

问题


I have a java code and created a jar file. I need to create an Qt application. Can I use this code in that application? Please help me how can i use that jar file.

Thanks, Nagaraju.


回答1:


You could take a look at the capabilities of GCC/GCJ (see http://gcc.gnu.org/ ). IF it's a good idea is a whole other story, and depends on what you have, and what you're trying to accomplish. It should be doable to link SO's created with GCJ in QT applications, but I seriously wonder if you are not better off using either C++ or Java, but not mixing them




回答2:


If your Java code takes input from stdin or some file and writes output to stdout or some file, then the easiest way is to fork java to run that jar, and parse the output in your Qt code.

Things other than that, you'll need to be a bit specific. Something like "my Java code does painting the screen".




回答3:


My advice is to use SWT or Swing.




回答4:


You can use gcj gcj to compile the java code to library and simply call the functions of the java code from your C code.




回答5:


Yes, you can use your jar file in your Qt application. I've done exactly this myself.

One way is to use the JNI Invocation API. This is part of the Java Native Interface (JNI), which makes it feasible but not pleasant to access Java APIs from C++.

A much more pleasant approach is to use CodeMesh JunC++ion, which wraps the Java APIs in C++ classes. This is a great product, if you can afford it.

If you have very little Java code, it may be easier to port it to C++.



来源:https://stackoverflow.com/questions/5887571/convert-java-jar-file-in-to-cpp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!