How to build Apache POI - Java API To Access Microsoft Format Files from sources? - apache-poi

I need to build https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas/4.1.2 project from sources. Since I didn't find any sources except these https://archive.apache.org/dist/poi/release/src/poi-src-4.1.2-20200217.zip I am trying to build them.
gradle build
...
* What went wrong:
Execution failed for task ':ooxml:ant-fetch-ooxml-xsds'.
> Can't get https://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%204%20(PDF).zip to /home/katya/tmp_work/poi-4.1.2/ooxml-lib/OfficeOpenXML-Part4.zip
Could you tell me where to get working sources of Apache POI version 4.1.2? I must build this library from sources version 4.1.2 .

Apache POI's source code can be obtained from the official SVN reposoitory or from the mirror GIT repository on GitHub.
Apache POI Developer Guide should give you enough information to get started. There's also a general readme on GitHub.
The "Apache POI - How To Build" section from the Apache POI Developer Guide:
Apache POI - How To Build
JDK Version
POI 4.0 and later require JDK version 1.8 or later.
POI 3.11 and later 3.x versions require JDK version 1.6 or later.
POI 3.5 to 3.10 required the JDK version 1.5 or later. Versions prior to 3.5 required JDK 1.4+.
Install Apache Ant
The POI build system requires Apache Ant version 1.8 - 1.9.x for Java 1.6 and higher. Newer versions (1.10.x) require Java 8 or higher.
The current source code has been tested to work with Ant version 1.9.x and 1.10.x.
Remember to set the ANT_HOME environment variable to where Ant was installed/extracted and add ANT_HOME/bin to your shell's PATH.
If you are unsure about the correct value for ANT_HOME, search your file system for "ant.jar". This file will be in the directory %ANT_HOME%/lib." For example, if the path to ant.jar is "C:/Programs/Ant/lib/ant.jar", then set ANT_HOME to "C:/Progams/Ant".
Install Apache Forrest
The POI build system requires Apache Forrest to build the documentation.
Specifically, the build has been tested to work with Forrest 0.90.
Remember to set the FORREST_HOME environment variable.
Building Targets with Ant
The main targets of interest to our users are:
Ant Target
Description
clean
Erase all build work products (ie. everything in the build directory).
compile
Compiles all files from main, ooxml and scratchpad.
test
Run all unit tests from main, ooxml and scratchpad.
jar
Produce jar files.
assemble
Produce .zip and tar.gz distribution packages.
docs
Generate all documentation (Requires Apache Forrest).
jenkins
Runs the tests which Jenkins, our Continuous Integration system, does. This includes the unit tests and various code quality checks.
Working with Eclipse
Apache POI includes a pre-defined Eclipse project file which can be used to quickly get set up in the Eclipse IDE.
First make sure that Java is set up properly and that you can execute the 'javac' executable in your shell.
Next, open Eclipse and create either a local SVN repository, or a copy of the Git repository, and import the project into Eclipse.
Right-click on "build.xml", and select "Run As / Ant Build...". The "Edit Configuration" dialog should appear. In the "Targets" tab, select the "Compile" target and click on "Run".
Note: when executing junit tests from within Eclipse, you might need to set the system property "POI.testdata.path" to the actual location of the 'test-data' directory to make the test framework find the required test-files. A simple value of 'test-data' usually works.
Working with IntelliJ Idea
Import the Gradle project into your IDE. Execute a build to get all the dependencies and generated code in place.
Note: when executing junit tests from within IntelliJ, you might need to set the system property "POI.testdata.path" to the actual location of the 'test-data' directory to make the test framework find the required test-files. A simple value of 'test-data' usually works.
Using Maven
Building Apache POI using Maven is not currently officially supported, and we strongly suggest continuing to use the official Ant build.
However, including Apache POI within your own Maven project is fully supported, and widely used. Please see the Components Page for details of the Maven artifacts available.
Setting environment variables
Linux: help.ubuntu.com, unix.stackexchange.com
Windows: en.wikipedia.org
by Glen Stampoultzis, Tetsuya Kitahata, David Fisher
-- https://poi.apache.org/devel/#Using+Maven

Related

UnsupportedClassVersionError when trying to build the platform

I'm trying to build the 1905 hybris platform but I keep getting this error:
java.lang.UnsupportedClassVersionError: de/hybris/ant/taskdefs/gradle/GenerateGradleProjectTask has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I've tried to change the JAVA_HOME from system variables but didn't worked.
Hybris 1905 needs Java 11. After you change JAVA_HOME, close the command-line / terminal (if it is open), and reopen it. In the command-line, do a java -version, and make sure it says Java 11.
Then inside the Hybris platform folder, run setantenv.bat (Windows) or setantenv.sh (Linux) before you build or start Hybris.

pom file java version spec for Maven

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.

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

Groovy plugin installation fails in STS 2.5.2 and 2.7

I have tried installing Groovy plugin via STS's dashboard install feature in both 2.7 (the version I downloaded initially which was the latest version at the time). My colleague recommended downloading 2.5.2, the version he is using, so I did; however the Groovy plugin installer still fails. It starts with:
Cannot complete the install because of a conflicting dependency.
Software being installed: Groovy-Eclipse Feature 2.5.2.xx-20110808-1400-e36 (org.codehaus.groovy.eclipse.feature.feature.group 2.5.2.xx-20110808-1400-e36)
Windows 7 64B
groovy v 1.8.2
grails v 1.3.7
jvm 1.6.0_26
Greatly appreciate any hints/recommendations/ideas. THANK YOU!
Make sure that your STS install is in a directory where the current user has write permissions. Also, there is a problem with installing into the Program Files directory (it is not really writable, even if you think it is).
The reason for this problem is the feature patch that comes with Groovy-Eclipse must be installed into the same directory as the rest of STS (an Eclipse limitation). This patch is the thing that patches the jdt compiler so that it can also compile groovy code.

Eclipse with JDK in Ubuntu 10.04

A short question: My eclipse project is set to use the "sun-java-6-jdk"-supplied JDK library, but I cannot Ctrl-click to view source (no source attached), as I can do out-of-the-box on Windows. How do I make this work?
You need to install the openjdk-6-source package and to attach the sources (located in /usr/lib/jvm/java-6-openjdk/src.zip) to the JDK under Eclipse.
Personally, I prefer to use sun-java6-jdk - the source package being sun-java6-source - that you can get from the Canonical Partner Repository:
deb http://archive.canonical.com/ lucid partner
Then, attach the sources located in /usr/lib/jvm/java-6-sun/src.zip
Presumably that's because it hasn't got source with the JAR so it's not finding it automatically. Your best bet is to consult the ubuntu package manager and see if there's a src, or if it's elsewhere on your system (/use/src or /use/local are places to start looking).
Once you've got it, you can right-click on the JAR in the project and point to the location of the Java source in the "source" property.
I think you need to go to the settings for your installed JRE, edit it, and set the source attachments manually.
Here's a link to Eclipse's help: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/preferences/java/debug/ref-installed_jres.htm

Resources