在我自己的项目中使用Java源代码

发布于 2024-10-16 11:50:02 字数 1455 浏览 8 评论 0原文

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

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

发布评论

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

评论(3

我纯我任性 2024-10-23 11:50:02

可能不会,OpenJDK 类受 GPL 约束,这意味着您也必须将源代码置于 GPL 下。 Oracle Java 类也属于“您不能只用我们的源代码做您想做的事情”,因此这很可能是一个非常糟糕的主意。

您可以使用 Retroweaver 使您的源代码与早期版本的 Java 兼容,但我想说您应该使您的代码与 Java 5 兼容,可选地使用 Java 6 工具(如果可用),然后告诉您的客户他们将得到哪些东西从升级。


2021 年编辑:从 Java 17 开始,正确的解决方案是将经过测试的 JVM 作为部署的一部分。有一些工具可以满足您的需求。

Probably no, the OpenJDK classes are under GPL meaning you will have to put your sources under GPL too. The Oracle Java classes are also under a "you cannot just do what you want to with our sources", so this is most likely a VERY bad idea.

You can use Retroweaver to make your source work with an earlier version of Java, but I would say that you should make your code work with Java 5, optionally using Java 6 facilities if available, and then say to your customers which things they will get from upgrading.


2021 edit: As of Java 17 the proper solution would be to include a tested JVM as part of your deployment. There is tooling for bringing just what you need.

天生の放荡 2024-10-23 11:50:02

您应该问的一个问题是:为什么您的客户端还没有升级到 Java 6.0?因为它是免费且容易做到的,所以他们必须有一个理由,并且您应该在向他们发送代码之前找出它是什么。

One question you should ask is: why haven't your clients upgraded to Java 6.0? Since it's free and easy to do they must have a reason, and you should probably find out what it is before sending them code from it.

海夕 2024-10-23 11:50:02

这取决于您要复制的源代码。来自JavaSE?开放JDK?

无论您想从哪里复制,请检查其代码许可证。

复制可能很简单,仅复制类及其依赖项。但可能存在很多特定的依赖关系,这可能会消耗大量时间。当您必须复制版本 5 中已存在的已更改的类时,您确实会遇到问题,其中某些代码需要一个版本,而另一个版本则需要较新的版本。但如果您只在该项目中使用 Java6 代码,那应该没问题。将类移动到另一个包中也可能是一种选择,但也可能需要做很多工作。

That depends on the source code you are copying from. From JavaSE? OpenJDK?

Wherever you want to copy from, check their license for the code.

The copying may be simple, copying just the classes and it’s dependencies. There may be a lot of specific dependencies though, which can make it consume a lot of time. And you’ll really have a problem when you have to copy a changed class that already existed in version 5, where you would need one version for some code, and the newer for the other. But if you’re only using Java6 code in that project it should be alright. Moving the classes into another package may also be an option, with potentially a lot of work as well though.

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