I am trying to import and use PDFBox, but am having issues installing the jars I believe.
I am using Dr. Java, and I have added both the pdfbox-1.8.6.jar and the pdfbox-app-1.8.6.jar to my resource locations in my Extra Classpath.
However, it still is not recognizing the jars when I run the code:
import org.pdfbox.cos.COSDocument;
import org.pdfbox.pdfparser.PDFParser;
What other steps do I need to do in order for the jars to work?
Use the correct imports:
import org.apache.pdfbox.cos.COSDocument;
import org.apache.pdfbox.pdfparser.PDFParser;
Additional hints:
pdfbox-app-1.8.6.jar contains the classes from pdfbox-1.8.6.jar, so you don't need pdfbox-1.8.6.jar too
if you want to load a document for rendering or text extraction, you won't need these two imports. Loading is done with
import org.apache.pdfbox.pdmodel.PDDocument;
PDDocument doc = PDDocument.loadNonSeq(new File(filename), null);
To see how it is done, look at the examples in the source code. Good luck!
Have you tried the steps detailed on the documentation:
Adding And Removing JARs in DrJava
A JAR file is a way of storing many (pre-compiled) Java classes. Below
are instructions for adding and removing jar files from DrJava's
resource locations. For more information on JAR files, see our JARs
page and Using JAR Files: The Basics on Sun's site.
How to add a JAR
When you download the jar, keep track of where you save it to
Open DrJava
Edit > Preferences
Resource Locations (at left)
In Extra Classpath, Add (browse and chose the new jar)
Apply
Okay
Quit DrJava and re-open it in order for the change to take effect
Related
I'm trying to use this library called OpenSimplexNoise, made by GitHub user TheCodingTrain. But I immediately discovered that I couldn't use it.
I did some digging to try to figure this out on my own, and I discovered that the JAR file and the main folder should have the same name (for example, the library file would be named OpenSimplexName and the JAR file would be OpenSimplexNoise.jar), and the folder the JAR file is in should be called "library." Once I fixed these issues, OpenSimplexNoise appeared in the "Import Library" menu in the "Contributed" section. But once I clicked it, a bunch of code appears:
import japplemenubar.*;
import processing.awt.*;
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.javafx.*;
import processing.opengl.*;
along with the error message:
More than one library is competing for this sketch.
The import japplemenubar points to multiple libraries:
core (C:\Program Files\Processing\processing.3.5.4\core)
OpenSimplexNoise (C:\Users**\Documents\Processing\libraries\OpenSimplexNoise).
Extra libraries need to be removed before this sketch can be used."
I tried removing japplemenubar, but the same issue appeared with processing.awt, so I tried removing that, but it just kept happening with each different import. I tried deleting it all and just typing "import processing.OpenSimplexNoise.*;", but it said "The import processing.OpenSimplesNoise cannot be resolved."
Does this mean that I'm just doing something wrong, or is this library no longer usable?
I recommend watching/following the videos linked in the README and understanding those:
https://youtu.be/pI2gvl9sdtE
https://youtu.be/U0TGZCEWn8g
The tutorials are how to put organize/compile a basic Processing library from scratch, not how to use library itself.
It would've been easier if a distribution zip would have been uploaded, but the point is learn how to generate it.
Downloading the library zip and unzipping in Processing won't work.
You need to:
(install eclipse if you haven't done so already as part of the video tutorial)
clone / download the project on your computer
Import the project into eclipse:
Drag and drop the build.xml file into the Ant panel: (in my view I've got multiple Processing libraries, you might have just OpenSimplexNoise)
Press the green Play Icon to run the build.
Initially I ran into this error:
BUILD FAILED
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:107: The following error occurred while executing this line:
/Users/George/Documents/eclipse/OpenSimplexNoise-for-Processing/resources/build.xml:141: /Users/George/Desktop/OpenSimplexNoise-for-Processing/lib does not exist.
Instead of trying to debug/fix the xml file I simply made the folder structure it wanted: a desktop folder named OpenSimplexNoise-for-Processing containing a lib folder.
Smooth sailing after this: BUILD SUCCESSFUL
Part of the ant build is copying the library to Documents/Processing/libraries so you can simply run the examples from there:
FWIW I've uploaded the compiled library here.
If simply wanted to use noise in Processing the built-in noise() function would do the trick.
If you want Simplex Noise without compiling Daniel Shiffman's example library you could try toxiclibs and it's toxi.math.noise package (also comes with an example sketch).
I'm working on trying to find a jar(s) file for the following imports. This is pertaining to a custom component for Oracle's UCM (Universal Content Manager). Two websites that come up no longer exist (findjar.com). I've been searching for possible code examples that would include the jars, but at this point, I have not found a solution. I've searched for websites that would aid me in finding the jar file that contains the class/path below. Is there another website that replaces findjar.com?
import intradoc.shared.*;
import intradoc.common.*;
import intradoc.data.*;
import intradoc.server.*;
import intradoc.resource.*
This file is available on the UCM server. You can locate it like this:
Log in as an administrator
Go to Administration / Configuration for ...
Expand class path details. There you will find something ending with wccontent/ucm/idc/jlib/idcserver.jar. That is the path on the server. Download that file and you have everything you need.
I'm kind of new with Processing 3.*; I am (and willing to) using the Processing Development Environment (The official IDE).
Reading the official "guide", in particular this part, it is specified that you can use pure Java language inside Processing simply naming a .java tab instead of a .pde one.
This kind of solution is good for example to use enums (otherwise not usable in .pde tabs) and there are other reasons, but they are not important at the moment...
A problem with this kind of work is that the libraries of Processing are not included, so you have to import them manually.
What I noticed is that all the official Processing libraries can be imported simply by the import keyword, while for all the libraries installed by the Contribution Manager the story is different.
The error message is The package "packageName" does not exists. You might be missing a library. Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.
Long story short I can't import those libraries...
I tried to copy them in the standard java libraries location (%SystemRoot%\Java\lib\ext) and in some other paths, but nothing...
I read that using classpath would allow as to use it but I can't understand how to use Processing with javac.
I also tried something like "ProcessingFolder\processing-java.exe" --sketch="$(CURRENT_DIRECTORY)" --run that is the same script you can use to run Processing in Notepad++, adding the statement --classpath="$(CURRENT_DIRECTORY)" (Obviously in Notepad++) but it didn't work (processing-java.exe state I don't know anything about --classpath=.).
So here's the question: How can we import and use libraries in .java tabs using Processing Development Environment?
That doesn't sound right. You should be able to use library classes just fine by importing them in a .java tab.
Step 1: From the PDE, go to Sketch -> Import Library, then choose the library you want to include. Notice that if you haven't included a library before, it's actually two steps: first you have to install the library, then you have to include it.
Step 2: Once you've included a library in your sketch, you can use the classes from that library anywhere in your sketch. This includes .java tabs.
Here's an example that uses the minim library in a .java tab. I didn't have to copy any files or create any directories:
Main sketch tab:
void setup(){
Test test = new Test(this);
}
Test.java tab:
import processing.core.PApplet;
import ddf.minim.Minim;
import ddf.minim.AudioPlayer;
import ddf.minim.AudioInput;
public class Test {
Minim minim;
AudioPlayer player;
AudioInput input;
public Test(PApplet sketch) {
minim = new Minim(sketch);
player = minim.loadFile("song.mp3");
input = minim.getLineIn();
}
}
It sounds like you aren't properly including the library in your sketch. Make sure you go through the Sketch -> Import Library menu, and make sure you both install and include the sketch.
I'm new in android, and I want to import the jfftpack to my project in android studio anda i don't know how to import it.
The original code was import ca.uol.aig.realdoublefft and I'don't know where to put the java files. I've tried to put them to a libs folder.
here's the jfftpack source code:
If it's an existing code library, I'd recommend adding a module for it. Probably the easiest way is to use the File menu command to add a new module, let it create a plain Java (non-Android) module for you, remove the sample class it puts into the module, and then copy your files over into it and tweak it. The module wizard will take care of setting up the directories and build files for you, and you can look at it later and see what did.
Without pressing Alt + enter to import the Packages?
There is some steps like
1)File --->Settings --from left pane we find editor---->General--->Auto Import
There
Insert imports on paste as ALL not ask
And put check mark for all the Above three Fields
1)Show import popup
2)Optimize the imports on fly
3)Add unambiguous imports on the fly
Click Apply and ok
Happy Coding......
If you have the sources import them in the src folder. Is the simple thing that you can do.
I suggest you to use the command line rather than Android Studio interface.
If you work on Linux or MacOS, try to copy the package to your working direcotry like:
cp -r PACKAGE_NAME PATH_TO/AndroidStudioProjects/PROJECT_NAME/app/src/main/java/
I am also new and had the same problem. I didn't have the package instruction at the top of the java file package com.example.myapp
I'm working through the example here:
http://www.vogella.com/articles/JavaPDF/article.html
In my file, I've got:
package com.mycompanyname.mydirectory;
import com.mycompanyname.OneOfMyClasses;
import com.itextpdf.text.Document;
...
public class MyClass {
...
}
Everything is working fine. What I don't understand is that since I just copied the import statement directly from the link above for the iText portion -- why does com.itextpdf.text.Document work?
I mean, if I look in directory com.mycompanyname I can see OneOfMyClasses.java there.
But in the com directly, there is no itextpdf directory (although maybe my user doesn't have permission to see it(?)).
Hoping someone can help me understand what I'm missing here. Doesn't the import point to a specific directory that I should be able to see the class? Is there a different com directory somewhere that iText is using, and com.itextpdf.text points to there? (if so, where's the directory located)?
I installed the jar file for iText in the lib folder as per usual, and made sure it was included in the classpath.
Those classes are inside a JAR file that is added to the classpath:
Create a new Java project "de.vogella.itext.write" with the package "de.vogella.itext.write". Create a folder "lib" and put the iText library (jar file) into this folder. Add the jar to your classpath.
import statements will look inside whatever directory trees are in the classpath, which includes the current directory at compilation time (tipically the src/ directory in your project) as well as any directory specified through environment variable or JVM startup parameter. See this about the classpath.
EDIT
You do need the imports whenever you use classes across packages. Every public class/interface you define is in a package. If whatever you are referencing belongs to another package, you need to import it.
JARs are zip files that contain directories and files inside. It's the same as plain directories and files, only packed.
It comes from the iText dependency (jar) you added in an earlier step.
Not necessarily - you could also import from libraries, etc.
In fact, Java will try to search through the classpath. Here is some helpful documentation.
That class is most probably imported in a JAR library. Inside such JAR file, the class files are kept in exact package/folder structure as you use when importing them.