简体   繁体   English

使用Java本机代码或C ++(QT,WxWidgets等)进行平台无关的编程

[英]Platform-independent programmming with Java native code or C++ (QT, WxWidgets etc.)

I am asking myself if it would be easier and more flexible to program a multiplatform application in Java and compile it to native binaries (the way Eclipse was written) or to use a cross-platform C++ framework like QT. 我在问自己,用Java编程多平台应用程序并将其编译为本地二进制文件(Eclipse的编写方式)还是使用跨平台的C ++框架(如QT)会更容易,更灵活。 Where are the advantages/disadvantages? 优点/缺点在哪里?

You will find less platform specific problems with Java, but: 您会发现Java平台问题更少,但是:

  • Some less commons platforms have C++ compilers/toolkits available but no JRE. 一些较不常用的平台具有可用的C ++编译器/工具包,但没有JRE。
  • With C/C++ you can usually access all native resources. 使用C / C ++,通常可以访问所有本机资源。 With Java that is not always the case. 使用Java并非总是如此。

It depends on your preferences. 这取决于您的喜好。 If you have much experience with C++, then stay to it. 如果您有C ++的丰富经验,请继续使用。 Platform-independence alone is not an argument, as Qt does an excellent job on guaranteeing platform-independent code and everybody can recompile a program on another system (that's actually what you want to do with your Java programs, too). 平台无关性本身并不是一个论点,因为Qt在保证平台无关代码方面做得很好,而且每个人都可以在另一个系统上重新编译程序(这实际上也是您要对Java程序进行的处理)。

I would just let the JVM do the compiling to native code. 我只是让JVM将其编译为本地代码。

You might assume its better to pre-compile it but for 98% of the time its not, it just harder and more complicated. 您可能会认为更好地预编译它,但是在98%的时间中,它不是更难,更复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM