简体   繁体   English

在Windows下如何在Java中运行Linux程序?

[英]How to run linux program in java under windows?

How can I run linux binary under windows? 如何在Windows下运行linux二进制文件? Is there some emulation jar or something to run linux program under windows from java program code like Runtime.getRuntime().exec()? 是否有一些仿真jar或某些东西可以从Java程序代码(如Runtime.getRuntime()。exec())在Windows下运行linux程序?

Assuming that you're asking if you're able to run a random Linux binary (ie, not a Java program built under Linux) under Windows, the answer is simple - no, not without building it as a Windows executable. 假设您要问是否能够在Windows下运行随机的Linux二进制文件(即,不是在Linux下构建的Java程序),答案很简单-不,不是没有将其构建为Windows可执行文件。

You should be able to run a 100% Java program on Windows and Linux unless you're making use of libraries that aren't available on both OSs. 除非您使用两个操作系统都不提供的库,否则您应该能够在Windows和Linux上运行100%Java程序。

对于任意(非Java)程序来说,这是完全不可能的。

您可以在Windows内使用装有Linux的虚拟机。

This not possible unless it's binary of an interpreted language (like Java binary). 除非它是解释语言的二进制文件(例如Java二进制文件),否则这是不可能的。 Also looks completely imposable to write a 'converter' between OSes: even slight difference in design of the OSes cannot be converted as it becomes necessary to write 'logic' converter!?? 在操作系统之间编写“转换器”看起来也是完全不可能的:操作系统的设计即使略有差异也无法转换,因为有必要编写“逻辑”转换器! (not even mentioning the numerous Unix implementations) Think of this: if to linux process means different thing from what it means to windows then how would this get converted ?:) It's not only syntactical but most importantly a logic difference which hurdles possibility of having what you need exist already. (甚至不提众多的Unix实现)想到这一点:如果linux进程与Windows意味着不同,那么它将如何转换呢?:)这不仅是语法上的,而且最重要的是,逻辑上的差异阻碍了具有您所需要的已经存在。

In some cases tool like cygwin can help you. 在某些情况下,诸如cygwin之类的工具可以为您提供帮助。 BTW if you wish to run windows program under linux you can use wine. 顺便说一句,如果您希望在Linux下运行Windows程序,则可以使用wine。

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

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