Can not find LucenePDFDocument class in pdfbox-2.0.2.jar - lucene

I want to parse pdf document to be indexed by Lucene using pdfbox package. The required class LucenePDFDocument which is in org.apache.pdfbox.examples.lucene.LucenePDFDocument package. But in the jar file I have not found it. So, my java program is not getting compiled.
Kindly help!!!

The answer of the question goes as follows...
Previously before pdfbox version 1.7.1, org.apache.pdfbox.examples package was included but there is no package as examples.lucene.LucenePDFDocument.
From 1.7.1 there is no org.apache.pdfbox.examples package.
So, in order to use LucenePDFDocument class in your application, one has to compile the source and make a jar and use it in the application. In the source there is a example package directory. So, example package will be included once compiled from source.

Related

Packaging a Jython program in an executable jar

I am trying to package a jython program into an executable jar which the user can simply double-click to run without installing jython ahead of time. Ultimately, I would like to include an additional library which I wrote with the jar, but at the moment I am just trying to package a simple program and have it run from the jar.
I have tried following the jar instructions in the "Using the Jar Method" section here: Jython FAQ: Using the Jar Method
I have also looked at slides 25-28 here: Jython Update 2012 slides
And finally here:
stackoverflow Question: Distributing My Python Scripts as Jars with Jython
I have installed jython 2.5.3, jvm 1.6, and python 2.7.3 on my mac which is running OS X 10.8.3.
These are the steps I go through to create the jar and run it:
Create a copy of jython.jar from my jython installation directory.
zip -r jython_copy.jar Lib (where Lib is the folder in the jython installation directory)
cp myJythonProgram.py __run__.py (myJythonProgram.py does not include an 'if name == main' line)
zip jython_copy.jar __run__.py
export CLASSPATH=/path/to/my/app/jython_copy.jar:$CLASSPATH
I have tried running the jar using all three of these methods:
java org.python.util.jython -jar myapp.jar
java -cp myapp.jar org.python.util.jython -jar myapp.jar
java -jar myapp.jar -jar myapp.jar
This works if my program doesn't use any import statements.
However I am running into an issue where some python packages are not able to be found when I run the jar. For instance, I get the error "ImportError: No module named random" when I include the line from random import random in my program. No errors occur on lines in the program when I import from javax.swing, java.awt, time, or math.
Additionally, I tried to package a jar with my library and a jython program which imports my library using the previous steps as well as the following additional steps:
zip jython_copy.jar myLibrary.jar
jar ufm jython_copy.jar othermanifest.mf
othermanifest.mf only contains the line Class-Path: ./myLibrary.jar.
This too gives the error "ImportError: No module named myLibrary"
I would appreciate any insight into what I am doing incorrectly or other steps I should take.
Thanks!
I realized what the problem was and I wanted to document it in case anyone else has the same problems.
I was using the jython.jar file that came in the standard installation of Jython, and NOT the standalone jython.jar (the instructions at Using the Jar Method mentions this, but the instructions at Building Jars do not). I am still unsure why copying the Lib/ folder of the standard installation into the jython.jar that came with that installation didn't work on my system. However, once I used the standalone jar, things started to work more smoothly.
Additionally, I was able to get my library to work with the packaged file by doing three things in addition to the steps I laid out in my question:
Exploding the standalone jython.jar and copying the folder with all of my library files into Lib, then create a new jar. This seemed to be the easiest way to include my library and allows me to package everything into a single jar.
I discovered after reading Frank Wierzbicki's answer in Why does Jython refuse to find my Java package? that because I am now using the standalone jar, I could no longer use imports of the style from java.awt import *, instead I needed to fully specify each thing I was importing, for example from java.awt.Font import PLAIN, BOLD, ITALIC. So I went through the library's imports and fixed the few that were of the wrong style.
Now that I am adding my Library directly to the Jar's Lib folder, instead of writing Class-Path: ./myLibrary.jar in othermanifest.mf, I put Main-Class: org.python.util.JarRunner as per Frank Wierzbicki's answer in the post I mentioned in my question: Distributing my Python scripts as JAR files with Jython?
This allowed me to create a double-clickable executable jar containing my library and jython file that I wanted to run.
There are two solutions. They both work, but one better than the other.
I believe you can rename your python script as __run__.py, place that file inside the .jar file, and pass the .jar file through a python interpreter. See https://wiki.python.org/jython/UserGuide#invoking-the-jython-interpreter for more.
Multiple methods to run Jython from the java code while running through JVM are described here, at the Jython documentation.
EDIT:
You can execute a command line code that runs the python file you want.
Link to an example of running command line code from java here.

I can not find for the source code repository for poi-ooxml-schemas

Alright, this is a little bit wierd. I've checkout apache-poi version 3.9 source code from
http://archive.apache.org/dist/poi/release/src/
But I can not find the source code for poi-xml-schemas. I have been googling but to no avail. Where is the code repository for these project? Is it a separate project from the poi source code or it is from some other project used as a library, but where is the code repository?
This is covered in the Apache POI FAQ (#14), from which I quote:
14. I can't seem to find the source for the OOXML CT.. classes, where do they come from?
The OOXML support in Apache POI is built on top of the file format XML Schemas, as compiled into Java using XMLBeans. Currently, the compilation is done with XMLBeans 2.3, for maximum compatibility with installations. (You can use the resulting classes on the XMLBeans 2.3 runtime, or any later version of XMLBeans. If you are currently using XMLBeans 2.2 or earlier, you will unfortunately have to upgrade, but this isn't common any more).
All of the org.openxmlformats.schemas.spreadsheetml.x2006 CT... classes are auto-generated by XMLBeans. The resulting generated Java goes in the ooxml-schemas-src jar, and the compiled version into the ooxml-schemas jar.
The full ooxml-schemas jar is distributed with Apache POI, along with the cut-down poi-ooxml-schemas jar containing just the common parts. The source jar isn't normally distributed with POI. It is, however, available from Maven Central - ask your favourite Maven mirror for the ooxml-schemas-src jar. Alternately, if you download the POI source distribution (or checkout from SVN) and build, Ant will automatically download the specification XML Schema, and compile it for you to generate the source and binary ooxml-schemas jars.
https://repo1.maven.org/maven2/org/apache/poi/ooxml-schemas/1.0/
has the ooxml schema ----- CTArray jar files.

Where is ChainedFilter class in Lucene .NET 3.0.3?

It was in Lucene.Net.Analyzers.dll in version 2.9.4. But i can't find this class in version 3.0.3.
Mindas: here is my comment since I cannot add a normal comment: how to access this ChainedFilter class? I have downloaded the package but there is no namespace like Lucene.Net.Contrib, or no other namespace which allows me to reach the ChainedFilter class. This seems silly but I am stuck!
UPDATE: There is a bug in the binaries from Nuget as well as zip files uploaded on apache site for Lucene.net. I downloaded the source and noticed that the ChainedFilter.cs class is present in the Apache-Lucene.Net-3.0.3-RC2.src\src\contrib\Analyzers\Filters folder, but this folder is surprisingly not a part of the Contrib.Analyzers project. That is why it was missing from the generated binaries.
Rephrasing this answer, you can either build it yourself or use Nuget to get the binaries.
http://nuget.org/packages/Lucene.Net.Contrib/
ChainedFilter should be under contrib/misc.
It looks like it is in org.apache.lucene.misc.ChainedFilter in Lucene 3.x.

org.jdom.Document cannot be resolve. It's indirectly referenced form required .class file

I try to work on RSS and receive the following error: org.jdom.Document cannot be resolve. It's indirectly referenced form required .class file.
I already added the jdom jar to my build path and tried different version but nothing worked.
I checked in the jdom jar, org.jdom.Document is not there, but jdom.src.org.jdom is there instead. If I extracted the source code of the jdom lib to my project and changed the package name to org.jdom, it would resolve the error.
However, I want to use the jar file only, not the actual source.Can anyone help me to resolve the error? Thanks!
Instead of JDOM 2,x, after download JDOM 1.1.3 and added the build/jdom-1.1.3.jar file into Eclipse build path, it fixed the problem.
I see you 'have it fixed'.... but, in case anyone else runs in to the same issue....
I expect that you have the jdom.zip file, not the jdom.jar file. The jdom.zip file is the distribution, and in the jdom/build directory you will find the actual jdom.jar file (or, depending on the version, jdom-1.1.3.jar ).
JDOM 2.x has a different release format (a zip file with a few jars....).
It is confusing, thus the different release format in 2.x
Rolf
I had the same issue and found that the Document or other classes which I was trying to import got changed under jdom2 in my jar. ie downloaded the jdom jars and added in my build path. So to import i changed to "import org.jdom2.Document" instead of "org.jdom.Document".
Check the class files in your jar package "jdom-2.0.6.jar" or in your specific version.
Dennis

Importing which library?

recently I downloaded this open source project and I am trying to compile it.
However, one of the line is giving me an error.
"import com.sun.org.apache.xpath.internal.functions.WrongNumberArgsException;"
Seems that i am missing a library.... is there a way to know WHICH library do I need?
I tried searching on google for com.sun.org.apache.xpath.internal.functions,
while there seem to be a result on kickjava.com/src containing the source code.
I think i need the Jar file right?
I tried downloading xalan from apache and it didn't work.
I tried to see if there's a xpath library, but I dont think there's a xpath library?
searching for xpath led me to xalan.
I have also tried Xerces-J-bin.2.9.1 .
Thanks!
The WrongNumberArgsException class in Xalan is in the org.apache.xpath.functions package. With the Xalan jar in your project, you should just be able to change the import statement in the open source code to use the correct path.
The OpenSource author (what ever "this open source project" is) imported the internal exception class from the sun adopted xalan classes in Java 6. This should not be done at all! Will not work with older VMs and may be broken with later ones.
Never import com.sun.*!