开发者

Using Java Source Code in my own project [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about programming within the scope defined i开发者_StackOverflown the help center.

Closed 7 years ago.

Improve this question

I wrote a program in Java 6.0, but it turns out that some of our client only have 5.0.

The issues is that lot of features that 6.0 has was not in 5.0 yet. For example:

  • JTable Sorting, Filtering feature
  • SwingWorker class

My Question is :

  1. is it legal to just copy the java 6.0 source code to my own project so that my client with 5.0 jre can run it.
  2. from technical point of view, is it hard to copy the classes source code like TableRowSorter, regexFilter to my own project and let it work?

Thanks


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜