Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK7/OpenJDK support #15

Closed
virl opened this issue Jan 26, 2017 · 6 comments
Closed

JDK7/OpenJDK support #15

virl opened this issue Jan 26, 2017 · 6 comments

Comments

@virl
Copy link

virl commented Jan 26, 2017

It seems that currently published Maven artifact for this project is built using JDK8 and thus doesn't work on JDK7 or OpenJDK.

It gives following error when project compiled with it tries to use OpenCV classes on JDK7:

OpenJDK Runtime Environment (rhel-2.6.8.0.el7_3-x86_64 u121-b00)
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)

OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/opencv_openpnp7480646247061802930/nu/pattern/opencv/linux/x86_64/libopencv_java320.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/opencv/core/Core : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at nu.pattern.OpenCV$LocalLoader.<init>(OpenCV.java:296)
	at nu.pattern.OpenCV$LocalLoader.<init>(OpenCV.java:290)
	at nu.pattern.OpenCV$LocalLoader$Holder.<clinit>(OpenCV.java:300)
	at nu.pattern.OpenCV$LocalLoader.getInstance(OpenCV.java:304)
	at nu.pattern.OpenCV.loadLocally(OpenCV.java:287)

The rest of the same app (other classes, not related to OpenCV bindings) work on that JDK just fine.

@vonnieda
Copy link
Member

JDK 7 has been end of life since April, 2015. OpenJDK 8 has been available since 2014. Is there a reason you are still using 7?

@virl
Copy link
Author

virl commented Jan 26, 2017

@vonnieda I'm developing project which will be working in the hosting environment I have little control, so I need maximum flexibility. In my experience of developing such java server-side projects, large IT companies prefer stable and open versions of SDK which come standard with Linux OS.

Current widely used server linux distro CentOS 7 includes OpenJDK 7 by default.

Anyway, I don't think your bindings are using any of Java 8 features and supporting JDK7 for you is just a matter of specifying -source and -target build keys when packaging it. It is common practice for libraries to require only previous version of platform to increase library's availability.

@vonnieda
Copy link
Member

@virl As I said, JDK 7 was end of lifed in April of 2015. That means it is not longer recommended for new applications. The current JDK is 8 and has been for for over 2.5 years. JDK 9 is about to be released and then we'll see 8 end of lifed.

The difficulty in doing this is that I don't control the build scripts used by OpenCV to build the OpenCV jar. I run the standard OpenCV build process and then bundle the generated jar. For me to switch the source and target for that jar I'd have to patch the OpenCV build scripts which I don't want to do.

If you can suggest an easy way to do this, or better yet, provide a pull request, I'm willing to include it.

@virl
Copy link
Author

virl commented Jan 26, 2017

@vonnieda What you saying about end-of-life is true for client apps, not libraries. Most libraries (even latest versions) on Maven still use JDK 7 if they're not requiring Java 8 features.

As for build process, the JDK source and target version is specified in pom.xml. Usually you do not need to change anything else (and don't need to install JDK7 to build it, of course).

@vonnieda
Copy link
Member

@virl OpenCV does not use Maven to build, it uses Ant. I do not control the build scripts for the OpenCV part of the build, only the wrappers. So to do this we would have to patch the OpenCV build scripts before building OpenCV. Note that my pom.xml already does specify 1.7 https://github.com/openpnp/opencv/blob/develop/pom.xml#L146 but that is not the one that matters.

As I said, if you are willing to provide a pull request to fix this I am happy to include it.

@virl
Copy link
Author

virl commented Jan 26, 2017

@vonnieda Ok thanks for reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants