简体   繁体   English

GCJ:Java本机代码,不会在其他计算机上运行

[英]GCJ: Java native code, won't run on other machines

I tried GCJ and it compiled fine. 我尝试了GCJ ,它编译良好。 I tried both for Ubuntu and windows. 我同时尝试了Ubuntu和Windows。 The compiled file is running on my Ubuntu machine as well the .exe with wine. 编译的文件以及我的Wine文件都在我的Ubuntu计算机上运行。 But if I tried to run in on my Ubuntu server I got this error: 但是,如果我尝试在Ubuntu服务器上运行,则会出现以下错误:

error while loading shared libraries: libgcj.so.14: cannot open shared object file: No such file or directory

But I thought I would not need to install anything to run "native" code. 但是我认为我不需要安装任何东西即可运行“本机”代码。 I also could not run the .exe on a windows machine. 我也无法在Windows计算机上运行.exe。

Could you please tell me why this is happening? 您能告诉我为什么会这样吗? Maybe I'm compiling wrong. 也许我编译错了。 I use this: gcj --main=Hello -o hello.exe Hello.jar for windows. 我用这个: gcj --main=Hello -o hello.exe Hello.jar Windows的gcj --main=Hello -o hello.exe Hello.jar

When you run an executable it is very common to need a shared library, whether you use Visual Studio .NET or Java or C++. 运行可执行文件时,无论使用Visual Studio .NET还是Java或C ++,通常都需要共享库。

When you compile a program for a specific platform, it usually only works on that platform or similar. 当您为特定平台编译程序时,该程序通常只能在该平台或类似平台上运行。 If you want to run this program on Windows, you need to compile it for windows. 如果要在Windows上运行此程序,则需要为Windows编译它。

BTW GCJ is pretty old and out of date. BTW GCJ很老,已经过时了。 I suggest you use Java 7 or 8. This will avoid the need to install additional libraries and will run on Windows or Linux without re-compiling. 我建议您使用Java 7或8。这将避免安装其他库,并且无需重新编译即可在Windows或Linux上运行。

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

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