pom file java version spec for Maven - linux

I am a new user to Maven, as I am trying to use it to build apache spark on amazon EC2 VMs. I have mannually installed java version 1.7.0 on the VMs. However as I was running the Maven, the following error occurs:
Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.0:testCompile (scala-test-compile-first) on project spark-core_2.10: Execution scala-test-compile-first of goal net.alchim31.maven:scala-maven-plugin:3.2.0:testCompile failed. CompileFailed
As I think the java version mismatch is the potential reason, causing the compiling problem. I opened up the pom file of the spark for maven tool, it has declared java related version in two seperate places:
<java.version>1.6</java.version>
and
<aws.java.sdk.version>1.8.3</aws.java.sdk.version>
What are the differences between these two versions?
Which one should be edited to solve the jave version mismatch?

It's two different things
<java.version>1.6</java.version>
is the java version used and
<aws.java.sdk.version>1.8.3</aws.java.sdk.version>
is the AWS SDK for Java version used.
The minumum requirement of AWS SDK 1.9 is Java 1.6+ so there is no compatibility issues.

Related

Uninstall pre installed java library from the databricks

There are some pre installed java libraries in azure databricks https://docs.databricks.com/release-notes/runtime/6.6.html#installed-java-and-scala-libraries-scala-211-cluster-version
Is there a way to uninstall such libraries?
I have a library conflict. I need to use another version of the spring-core library.
Databricks includes a number of default Java and Scala libraries. You can replace any of these libraries with another version by using a cluster-scoped init script to remove the default library jar and then install the version you require.
Important Note: Removing default libraries and installing new versions may cause instability or completely break your Databricks cluster. You should thoroughly test any new library version in your environment before running production jobs.
Refer: Databricks - Replace a default library jar.

OWASP security issue with jackson-databind-2.9.8 jar

I have a maven web project(RESTful, Spring Rest/data) running in Java 8(tomcat 8.5.5) and using 'jackson-databind-2.9.8.jar'. When the Dependency Check Tool(Checks vulnerable jar version and generates report) is run against the libraries the project is using, it showed 'jackson-databind-2.9.8.jar' as Vulnerable(Reference- https://nvd.nist.gov/vuln/search/results?form_type=Advanced&results_type=overview&search_type=all&cpe_vendor=cpe%3A%2F%3Afasterxml&cpe_product=cpe%3A%2F%3Afasterxml%3Ajackson-databind&cpe_version=cpe%3A%2F%3Afasterxml%3Ajackson-databind%3A2.9.8)
Problem:- Changing to 'jackson-databind-2.10.0.jar' version fixes OWASP security issue(running Dependency Check Tool) but, when project is build and run it throws error since 2.10.0 uses jdk9+ complaint classes(Reference- https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.10)
What should be done to resolve the issue, can we make the project compile in Java 8 and run in JDK11(since JDK9 is out of support) or something else should be done? Please suggest.
Thanks in advance!
CVE-2019-12086 is fixed in jackson-databind-2.9.9.jar .
See the report: https://nvd.nist.gov/vuln/detail/CVE-2019-12086
Maven repo for 2.9.9 : https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.9.9

What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?

I'm trying to run some JavaFX code with Eclipse Kepler, with e(fx)clipse plugin installed, on a Linux machine, using:
java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-5)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
My understanding is that although JavaFX has been included with the standard JDK since version JDK 7u6, the JavaFX runtime JAR file, jfxrt.jar, was left off of the Java runtime path on purpose until further testing between JavaFX and rest of the java infrastructure has been completed. For this reason you must manually add it to the project build path libraries when we create a new Java project.
I've been looking for that jar in both the following directories without success:
/usr/lib/jvm/java-7-openjdk-common/jre/lib/
/usr/lib/jvm/java-7-openjdk-amd64/lib
Where else should I look for it?
Update March 2021
The previous information in this answer is now obsolete for later versions of Java and JavaFX (e.g. Java 11+). This update provides info for more recent versions.
JavaFX is now available from openjfx.io or the public Maven repository as an SDK or a library set, or a module set. JavaFX has been partitioned into a set of dependencies rather than a monolithic jfxrt.jar library distributed with the Java runtime (as was previously the case with Oracle Java 8 for instance).
With versions 11+ of JavaFX, the location of the JavaFX jar files (and the native libraries to accompany them) will depend on how you build your project. For example:
If you use a build tool such as Maven or Gradle and specify JavaFX as a dependency, then the JavaFX jar files will be downloaded into your local Maven or Gradle repository (the same as other maven dependencies).
If you download the JavaFX SDK from openjfx.io (gluon), then the JavaFX jar files will be in the location you unzipped the SDK to.
The location of jfxrt.jar in Oracle Java 7 is:
<JRE_HOME>/lib/jfxrt.jar
The location of jfxrt.jar in Oracle Java 8 is:
<JRE_HOME>/lib/ext/jfxrt.jar
The <JRE_HOME> will depend on where you installed the Oracle Java and may differ between Linux distributions and installations.
jfxrt.jar is not in the Linux OpenJDK 7 (which is what you are using).
An open source package which provides JavaFX 8 for Debian based systems such as Ubuntu is available. To install this package it is necessary to install both the Debian OpenJDK 8 package and the Debian OpenJFX package. I don't run Debian, so I'm not sure where the Debian OpenJFX package installs jfxrt.jar.
Use Oracle Java 8.
With Oracle Java 8, JavaFX is both included in the JDK and is on the default classpath. This means that JavaFX classes will automatically be found both by the compiler during the build and by the runtime when your users use your application. So using Oracle Java 8 is currently the best solution to your issue.
OpenJDK for Java 8 could include JavaFX (as JavaFX for Java 8 is now open source), but it will depend on the OpenJDK package assemblers as to whether they choose to include JavaFX 8 with their distributions. I hope they do, as it should help remove the confusion you experienced in your question and it also provides a great deal more functionality in OpenJDK.
My understanding is that although JavaFX has been included with the standard JDK since version JDK 7u6
Yes, but only the Oracle JDK.
The JavaFX version bundled with Java 7 was not completely open source so it could not be included in the OpenJDK (which is what you are using).
In you need to use Java 7 instead of Java 8, you could download the Oracle JDK for Java 7 and use that. Then JavaFX will be included with Java 7. Due to the way Oracle configured Java 7, JavaFX won't be on the classpath. If you use Java 7, you will need to add it to your classpath and use appropriate JavaFX packaging tools to allow your users to run your application. Some tools such as e(fx)clipse and NetBeans JavaFX project type will take care of classpath issues and packaging tasks for you.
Mine were located here on Ubuntu 18.04 when I installed JavaFX using apt install openjfx (as noted already by #jewelsea above)
/usr/share/java/openjfx/jre/lib/ext/jfxrt.jar
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
On Ubuntu with OpenJDK, it installed in /usr/lib/jvm/default-java/jre/lib/ext/jfxrt.jar (technically its a symlink to /usr/share/java/openjfx/jre/lib/ext/jfxrt.jar, but it is probably better to use the default-java link)
The location of jfxrt.jar in JDK 1.8 (Windows) is:
C:\Program Files\Java\jdk1.8.0_05\jre\lib\ext\jfxrt.jar

javafx deployment using java 6

I just package my JavaFX app using the provided tool. But when I try to run it using java -jar app.jar I get a message asking me to install a newer Java version. I'm using 6u33 withfx 2.2beta` in development environment and is running fine. So, my question is, what is the required config to run under Java 6?
Here is my package command:
\javafx-sdk2.2.0-beta\bin\javafxpackager.exe -createjar -appClass gui.principal.FrmPrincipal -classpath lib\jfxrt.jar;lib\antlr-2.7.7.jar;lib\dom4j-1.6.1.jar;lib\hibernate-commons-annotations-4.0.1.Final.jar;lib\hibernate-core-4.1.4.Final.jar -srcdir classes -outdir dist -outfile Etransporte.jar -V
Thanks!
Well, a couple of hours later I downloaded the final version of JavaFX SDK and installed it over my Java 6u33 SDK and everything worked fine since then. So, upgrade is the rule.
No need to use the beta sdk, use the production sdk. The beta sdk may have unresolved bugs and is not suitable for packaging applications for general deployment.
Just some general info, I think you probably have most of this covered already, but something might be useful.
Here is a sample batch script for packaging a javafx application with javafxpackager.exe. Offhand the command you are running looks fine.
Ensure that the java system and javafx installation on your test machine are both the same bit architectures (e.g. 32bit or 64bit). Also jre6+javafx2.2 is only supported on Windows machines, not Linux or Mac.
Note that if your client machine only has jre 6 installed and not the JavaFX runtime, then it is expected when you run your packaged app on that system that it will provide some prompt and help to allow the user to install the JavaFX runtime on the client.
Also note, that not all versions of jre6 are supported by JavaFX 2.2, it must be a recent version of jre6 (2.2 requires Java SE 6 Update 33). It does seem that you are running the right minimum version.

JAXB jar files incompatible with java 1.6.0?

I'm new to JAXB and I want to marshal and un-marshal XML/Objects to Objects/XML.
I have downloaded JWSDP 2.0 from (worth 22.69 MB) Sun's site.
I have set Environment variables as
JAVA_HOME :- D:\Program Files\Java\jdk1.5.0
JWSDP_HOME :- D:\Sun\jwsdp-2.0
JAXB_HOME :- D:\Sun\jwsdp-2.0\jaxb
PATH :- D:\Program Files\Java\jdk1.5.0\bin;D:\Sun\jwsdp-2.0\jwsdp-shared\bin;
I'm trying to compile a simple XSD file (named tp.xsd) using XJC (which is present in D:\Sun\jwsdp-2.0\jaxb\bin).
I'm getting the following output when I try to compile it:
D:\Sun\jwsdp-2.0\jaxb\bin>xjc tp.xsd
parsing a schema...
compiling a schema...
generated\Bookdata.java
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getSimpl
eName()Ljava/lang/String;
at com.sun.codemodel.JCodeModel$JReferencedClass.name(JCodeModel.java:54
5)
at com.sun.codemodel.JFormatter.t(JFormatter.java:283)
at com.sun.codemodel.JClass.generate(JClass.java:358)
at com.sun.codemodel.JFormatter.g(JFormatter.java:346)
at com.sun.codemodel.JAnnotationUse.generate(JAnnotationUse.java:388)
at com.sun.codemodel.JFormatter.g(JFormatter.java:346)
at com.sun.codemodel.JDefinedClass.declare(JDefinedClass.java:767)
at com.sun.codemodel.JFormatter.d(JFormatter.java:372)
at com.sun.codemodel.JFormatter.write(JFormatter.java:402)
at com.sun.codemodel.JPackage.build(JPackage.java:434)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:297)
at com.sun.codemodel.JCodeModel.build(JCodeModel.java:287)
at com.sun.tools.xjc.Driver.run(Driver.java:378)
at com.sun.tools.xjc.Driver.run(Driver.java:196)
at com.sun.tools.xjc.Driver._main(Driver.java:121)
at com.sun.tools.xjc.Driver.access$000(Driver.java:79)
at com.sun.tools.xjc.Driver$1.run(Driver.java:101)
Can you help me finding the solution? I know that the error
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getSimpl eName()Ljava/lang/String;
occurs due to compiler and class file incompatibility, but I'm not getting what to do!
When I run java -version command it shows:
C:\Documents and Settings\welcome>java -version
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Client VM (build 19.0-b09, mixed mode, sharing)
The jaxb libraries are included in java 1.6. You'll get all kinds of crazy classloader errors if you add the jar too.
In this case, it looks like it xjc picked the wrong version of the jar.
edit
xjc should be bundled in the JDK, in your post you are using the xjc that comes in the jabx stand-alone pack. Go to the folder where you installed java 1.6, check that you have the xjc.exe or xjc.bat there and run it from that folder.
And like Robert mentioned above, be sure that you're using Java 1.6
This is a supplemental answer to the original post. The question on the comments section was:
(But my system was updating java regularly so why didnt it download latest things which are in java 1.6 but not in java 1.5??? why my system was saying i'm running java 1.6 as shown in my question??)
When you type "java -version" on the command prompt, Windows resolves it using the PATH environment variable. There are multiple locations where one can find the java.exe file. The obvious one is the location of the downloaded JRE (i.e. C:\Program Files (x86)\Java[SOME JRE]). Another, no so obvious, location is Windows' System32 folder. I also just found out that my Windows 8 machine has a java.exe shortcut under C:\ProgramData\Oracle\Java\javapath. The point is that could be many paths where the java.exe (or shortcut) can reside. The one encountered first in the PATH wins out.
If you want a specific version of java to be used to execute programs outside your development environment, you must place that location as the first entry in the PATH (to make sure it finds that location first).

Resources