使用cygwin将java文件编译为windows本机代码

发布于 2024-11-13 07:05:23 字数 203 浏览 3 评论 0原文

我为我的一项作业编写了一个小型 Java 应用程序。问题是老师可能没有安装JRE。我想要将java文件编译为window exe文件,以便老师可以在不安装JRE的情况下运行它。

我在 cygwin 中使用 gcj 工具,但输出应用程序似乎需要 cygwin1.dll 才能运行。我怎样才能避免这种情况,IE将应用程序需要的所有东西打包到一个文件中,这样老师就不必安装任何东西。

I have written a small java application for one of my homework. the problem is the teacher may not have JRE installed. what i want to id to compile the java file to window exe file so the teacher can run it without the JRE installed.

i use the gcj tool in the cygwin , but the output application seem to need the cygwin1.dll to run. how can i avoid this, IE package all the things the application need to a single file, so the teacher don't have to install anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囍笑 2024-11-20 07:05:24

使用 MinGW 而不是 Cygwin。

并准备好 10 MiB 的可执行文件。

Use MinGW instead of Cygwin.

And get ready for a 10-MiB executable.

你穿错了嫁妆 2024-11-20 07:05:24

你为什么不直接要求你的老师安装一个 JRE,或者如果他们有 JRE 的话?如果您被允许使用 Java,那么我确信老师将需要拥有正确评估您作业的工具。

如果您被允许使用Java,那么,您在想什么?

Why don't you just ask your teacher to install a JRE, or if they have one? If you are allowed to use Java, then I'm certain the teacher will be required to have the tools for properly evaluating your homework.

If you weren't allowed to use Java, well then, what were were you thinking?

鯉魚旗 2024-11-20 07:05:24

应用程序似乎需要 cygwin1.dll 才能运行。

在 Windows 上,将 .exe 与一组 .dll 文件一起传送是很常见的。

如果您使用 Microsoft Visual Studio,您的程序还需要附带 Visual Studio Redistributable Run-Time 中的一些库。 (除非您静态链接它。)Windows 上的大多数主要应用程序的安装目录都充满 dll 文件,没有它们就无法运行。

2016 年中,Cygwin 项目将许可从 GPL 更改为 LGPL。这意味着您可以将程序链接到 cygwin1.dll 并重新分发它们,即使这些程序具有与常规 GPL 不兼容的许可证,例如闭源、不可自由再分发、专有程序。 (当然,如果您在重新分发 cygwin1.dll 本身时遵守 LGPL)。

IE 将应用程序所需的所有内容打包到一个文件中,因此教师无需安装任何内容。

不安装任何内容的唯一方法就是根本不存在文件。如果有一个文件,则必须将其放置在某个位置,并且满足安装的定义。在 Windows 上,如果您有一个依赖于 .dll.exe 文件,您只需确保将它们放入同一目录即可。如果程序太不重要以至于无法保证开发完整的安装程序,则可以通过将它们放入 .zip 文件中来轻松满足此要求。

您的老师将您的 .zip 文件解压到桌面上或下载目录中。应该会出现一个文件夹,该文件夹中包含您的程序和 dll。可以调用程序并加载dll;不用想也知道。

The application seem to need the cygwin1.dll to run.

Shipping an .exe with an cluster of .dll files is the norm on Windows.

If you use Microsoft Visual Studio, your program will also need be shipped with some libraries from the Visual Studio Redistributable Run-Time. (Unless you link it statically.) Most major applications on Windows have installation directories chock full of dll files, and won't run without them.

In the middle of 2016, the Cygwin project changed the licensing from GPL to LGPL. This means you can link programs with to cygwin1.dll and redistribute them, even if those programs have a license that is not compatible with the regular GPL, such as closed-source, non-freely-redistributable, proprietary programs. (If you otherwise comply with the LGPL in regard to how you are redistributing cygwin1.dll itself, of course).

IE package all the things the application need to a single file, so the teacher don't have to install anything.

The only way not to install anything is not to have a file at all. If there is a single file it has to be put somewhere, and that meets the definition of installation. On Windows, if you have a .exe file that depends on a .dll, all you have to ensure is that they are put into the same directory. This requirement can be met as easily as by putting them into a .zip file, if the program is too unimportant to warrant developing a full blown installer.

Your teacher unzips your .zip file on their Desktop, or in their Downloads directory. A folder should appear, and in that folder is your program and the dll. The program can be invoked and loads the dll; no brainer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文