Using Java Source Code in my own project [closed] - java

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 in 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 :
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.
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.

Related

Is it possible to use ConcurrentHashmap compute with java 7 source level?

We have an old project using gwt 2.6 and therefore we need to compile with -source 1.7 option.
The JRE and JDK used are 1.8, but compile with 1.7 source code option.
We want to use the new compute function from ConcurrentHashMap which is only available from java 8. When using eclipse and maven everything compiled well. On the other hand IntelliJ is complaining. My question is, will it work or will we have issues with it?
Will this project run?
Searching in google for ConcurrentHashmap compute, java 8 and source code level 1.7 did not give any info.
If at all, this would require a lot of careful "manual" work.
When you look at this question for example, you can find that there are various different ideas how people want to enable "stream based" functional programming with Java 7. Maybe, after doing a lot of research, you might be able to find similar things regarding such "enhanced collection" features.
But then, all of that might be quite fragile. The fact that some examples might work fine wouldn't mean that you would be able to run a large production code base on a Java 7 VM.
Thus more of a non-answer here: be careful how to invest your time and energy. Instead of trying to backport libraries to Java 7, rather look into moving your whole project onto Java8 at least. Especially keeping in mind that the release cadence for Java has changed significantly, and going with outdated Java versions for many years is simply even less desirable compared to a few years ago.
Well, the simple answer is that it will not work. The target runtime will not have the updated API (i.e., the compute*** methods won't be on the version of Map that Java 7 has).
So if you deploy that code, the runtime will understand the class version, but will raise NoSuchMethodError and similar errors.
In addition to this, there are many reasons for upgrading your runtime.

JEP 12: Preview Language and VM Features - possible usage testimony [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I bumped into JEP 12 searching for JDK 12 and was intrigued.
Summary: A preview language or VM feature is a new feature of the Java
SE Platform that is fully specified, fully implemented, and yet
impermanent. It is available in a JDK feature release to provoke
developer feedback based on real world use; this may lead to it
becoming permanent in a future Java SE Platform.
Following the responses to this question, I wish to ask only the following:
Can you provide a usage example of this JEP- incorporation of new language and/or VM features in code?
Does this mean that usage of new features will now be as simple as downloading a support jar and 'plugging' it into our projects?
No. This is about enabling "preview" features in the Java language and the JVM, so that a feature can gain wider exposure and feedback (with suitable opt-ins) before being finalized. (If you could just enable an experimental / preview feature by dropping in a JAR file, this mechanism wouldn't be necessary ...)
In fact, with the "preview" mechanism as described in the JEP:
any code supporting a preview feature would already part of the JRE / JDK, and
the features would be enabled by providing extra command line options to the javac and java commands.
Can anyone share any usage experiences of this JEP? Actual code?
Compiler and VM support for preview features will be supported starting in Java 11, and we will likely see the first preview features in Java 12. Looking at the early access build release notes, they don't explicitly mention any "preview" features. Yet.
It is too soon for "experiences". (And I'm not sure what they would tell you. The JEP-12 mechanism is the mechanism for enabling the features ... not the features themselves.)
I also looked into the JIRA issue related to this JEP, it seems that this feature is currently completed but unresolved.
The issue is an "umbrella" issue (if that is the correct term). Drill down to the list of related issues, and you will see that two of them are still unresolved. However three related issues are resolved, so it looks like JEP-12 support will make it into Java 11.
UPDATE: 2019/08/22 - There is now just one relatively small issue about improving javac compiler messages.

Java version upgrade to 8 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know that similar questions have already been answered, but I have a specific question for which it would be great if someone can throw some light.
I am trying to migrate a couple of applications (desktop apps using Swing) to Java version 8. Currently the version used for compiling as well as running) is 6.
There are a large number of third party APIs (which are no longer supported) used by these two apps which are compiled using JDK 5.
I plan to compile the applications using JDK 8 but to avoid any more complications (and rework) want to keep the 3rd party APIs as it is (compiled on version 5) even though I do have the whole source code of the APIs.
Do you think it is a good idea and what are the points I need to be careful about.
Edit :
To precise my qustion here - considering the behaviorial and source incompatiblities between Java 5 and Java 8, is it possible and probable in practical terms that an API compiled with version 5 works perfectly fine with JRE 8, but wen I try to recompile it with JDK 8, it fails with compilation errors?
Thanks in advance
Generally old code runs without problems on newer JVM.
There are very few exceptions that need to be considered.
They are listed in the java 8 compatibility guide.
Each incompatibility is listed with a number.
As an example removeAll in the class Collection has a different behaviour if you pass a null parameter in java 8:
RFE 7131459
Area: Core Libs / java.util.collections Synopsis In previous
releases, some implementations of Collection.removeAll(Collection) and
retainAll(Collection) would silently ignore a null parameter if the
collection itself was empty. As of this release, collections will
consistently throw a NullPointerException if null is provided as a
parameter.
Nature of Incompatibility behavioral
If your code has a complete set of unit test, you can run them using JRE of java 8 and check that none of them fails. If the coverage of unit test is complete you are quite sure that there will be no problem upgrading to java 8.

Downloading Eclipse's Source Code [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm doing a study on large Java projects and would like to view the source code for Eclipse. I have gone to this url (http://wiki.eclipse.org/index.php/CVS_Howto) and figured that the most useful cvs repository for me to look at would be this one:
:pserver:anonymous#dev.eclipse.org:/cvsroot/eclipse (The Eclipse platform project)
However, when looking at this repository, it has so many modules! Which modules should I be trying to check out? I don't necessarily want to build the IDE from source, however, I just want to get the core Eclipse code base to perform some analysis. Would I just check out any modules starting with "org.eclipse..."? Should I be checking out any of the others?
Or is there an easier way to get the source? I read somewhere that you can get the source from the binary version of Eclipse but I am unsure where to find the source.
Just download the source tarball eclipse-cvs.tgz from here
EDIT: This also includes version history, so it may be larger than you need. For just a current version download Platform-SDK.3.5.2 ~ 100MB
It includes the sources in jar files e.g.
org.eclipse.ui.workbench_3.5.2.M20100113-0800.jar
org.eclipse.ui.workbench.source_3.5.2.M20100113-0800.jar
For empirical studies, a good resource to check out is the Qualitas Corpus. It's a collection of open-source Java programs for use in empirical studies. In addition to having source code for a larger number of major projects (including Eclipse) they have multiple versions of each program, so you can track how code changes over time, if that's important. It's a respected corpus in the Software Engineering/Programming Languages research community, and so it may make your work more suitable for comparison in the future.
I'm not a part of their project, but I have used their corpus in a recent study. If you shoot them an email and tell them what your project is about, they'll give you http download access.
I can only answer this bit:
Or is there an easier way to get the
source? I read somewhere that you can
get the source from the binary version
of Eclipse but I am unsure where to
find the source.
In eclipse/plugins/, the jars named *.source_*.jar contain source. For example, in my install:
org.eclipse.osgi_3.4.0.v20080605-1900.jar
org.eclipse.osgi.source_3.4.0.v20080605-1900.jar
The first jar contains the OSGi runtime, and the latter contains the corresponding source.

Java licensing for commercial distribution [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm thinking of using Java to write a program that I might try to sell one day. I'm new to Java so I have to ask, what types of tools/software/etc will I need (from development, to distribution, to user-friendly installation on users' machines) that have licenses that must be considered to make sure they allow sales and closed source code, etc.?
Should we assume the user already runs at least one Java app, and therefore has a fairly recent version of Java on their machine?
Also, do you have any recommendations for specific tools that are definitely suitable for this purpose?
It's very rare to see any development tools that restrict the way you can use software created using them. The only exception to that are libraries, and that is not a problem with standard Java libraries. Tools, IDE and so on - regardless of whether they're free or not - will not affect how you can distribute your code.
There are some weird exceptions, like BitKeeper source control software, the license of which prohibits anyone using it from trying to create software that could compete with BitKeeper - which is why I advise to stay as far away from the thing, and the company behind it, as possible. In the end, if you want to be absolutely legally clear, you'll have to hire a lawyer and have him go through licenses and EULAs for all software you're going to use in your development process, because of stuff like this.
Some specific data points: Java itself is okay (both compiler and libraries); both Ant and Maven are okay; and Eclipse and NetBeans are okay.
For development, you will likely need an IDE. The top picks are:
Eclipse (most features)
IntelliJ (non-free)
Netbeans (easiest to learn, imo)
A few others with much lower popularity
For a free installation program, I've had the best experiences with IzPack, but there are others available. Similarly, to convert to a .exe for easy launching, I recommend Launch4J.
I don't think that its safe to assume that users have Java installed. Many will, but the versions will vary fairly widely, and the few that don't will tend to cause problems. Obviously, this may vary depending upon your intended audience (and how much control you have over them).
For cross platform distribution you might want to look into launch4j: http://launch4j.sourceforge.net/
Also you might also want to obfuscate and optimize your code, for that you can use ProGuard: http://proguard.sourceforge.net/
For your development use any of the open source tools available such as eclipse or netbeans, or even emacs with jdee.
You should not assume users have Java, package a version of java with your application.
For installation you might want to search for some open source solutions, the only one I know of is install4j and it is commercial. http://www.ej-technologies.com/products/install4j/features.html
This is a question that is really hard to answer because the requirement and the preferences of the users are different from each other.
But I will tell you one entry point. Use ECLIPSE as your IDE to develop your Java code. It is an opensource one so you don't need any licence for that. When you are working on your project you will need variety of other tools to do various stuff. Fortunately most of the essential functions are implemented as plugins for eclipse. You can seperately add them to eclipse.
With time, you'll get the experience and you will have enough knowledge to swich to the necessary tools etc

Categories