I'm creating a simple program in JAVA where there is a button that creates a PDF when clicked. I'm using iText JAVA library for generating the PDF.
I've included iText .jar file in "Java build path" but when I try to import classes of the library i get this error: The import com.itextpdf.cannot be resolved.
For example:
import com.itextpdf.text.BaseColor; // The import com.itextpdf.text.BaseColor cannot be resolved
import com.itextpdf.text.Document; // The import com.itextpdf.text.Document cannot be resolved
import com.itextpdf ... // and so on
It depends on whether you are using version 7 or 5 of iText. If you're using 7, the packages you will need to import change from com.itextpdf.* to com.itext.kernel.*, com.itext.layout.* etc.
Try to follow these steps:
Clean Your Eclipse Project: Go to Project > Clean in Eclipse (in menu above).
Refresh your project folder: (right click on your project > refresh).
Re-build your project.
And now you can select all JARs in that folder:( right click on project folder -> Build Path -> Add External Archives).
Related
I am a newbie to eclipse and eclipse plugins. I want to use zest project, with making some specific extentions . So I downloaded eclipse zest plugin source codes from the link below , I am trying to build this project under eclipse 3.7 . But manifest.mf gives error in this lines
org.eclipse.zest.internal.dot.parser.dot,
org.eclipse.zest.internal.dot.parser.dot.impl,
org.eclipse.zest.internal.dot.parser.dot.util,
org.eclipse.zest.internal.dot.parser.parseTreeConstruction,
org.eclipse.zest.internal.dot.parser.parser.antlr,
org.eclipse.zest.internal.dot.parser.parser.antlr.internal,
When i open the packages above, there are some missing files. For example , i see that there is no source of the classes below.
import org.eclipse.zest.internal.dot.parser.dot.AList;
import org.eclipse.zest.internal.dot.parser.dot.AttrList;
import org.eclipse.zest.internal.dot.parser.dot.AttrStmt;
import org.eclipse.zest.internal.dot.parser.dot.Attribute;
import org.eclipse.zest.internal.dot.parser.dot.AttributeType;
import org.eclipse.zest.internal.dot.parser.dot.EdgeRhsNode;
import org.eclipse.zest.internal.dot.parser.dot.EdgeStmtNode;
import org.eclipse.zest.internal.dot.parser.dot.GraphType;
import org.eclipse.zest.internal.dot.parser.dot.MainGraph;
import org.eclipse.zest.internal.dot.parser.dot.NodeId;
import org.eclipse.zest.internal.dot.parser.dot.NodeStmt;
import org.eclipse.zest.internal.dot.parser.dot.Stmt;
import org.eclipse.zest.internal.dot.parser.dot.Subgraph;
import org.eclipse.zest.internal.dot.parser.dot.util.DotSwitch;
I am not able to build from source ,-I think- since there are some missing source codes in git link.
do you have any solutions thank you .
The dot parser is an Xtext project that needs source code generated. At this point, it needs two manual steps:
Create a src-gen folder in the root folder of org.eclipse.zest.dot.core - this will become a source folder. Git does not upload empty folders in git.
Similarly create a src-gen folder in org.eclipse.zest.dot.ui.
Execute the org.eclipse.zest.dot.core/src/org/eclipse/zest/internal/dot/parser/GenerateDot.mwe2 workflow file (Run as/MWE2 workflow). This will generate all necessary code. If you did not create the source folders, this step would fail with a really cryptic error message.
hi all
i use the javazoom.jl.player.Player package but it is says The import javazoom cannot be resolved. i am using eclipse and doing Android project. i clean the project still the same error is shown. please correct me.
If eclipse can't resolve a package fragment of an import statement, then it tells you (with that error), that there is no library on the classpath that contains a class from that package (or from a package whose name starts with the missing part).
An easy way for standard java/eclipse:
create a folder lib in your projects root directory (with the eclipse workbench!)
copy and paste the jar into that folder
right-click the copied jar and select "add to build path".
This should eliminate the compiler errors immediately.
(Previous part of the answer)
Taking the error message literally, it looks like you have a line of code like that:
import javazoom;
This would be wrong, because we don't import packages but classes from a package. To import all classes from the javazoom package, we'd say:
import javazoom.*;
You should download the .jar of jLayer ( http://www.javazoom.net/javalayer/sources.html )
And add into classpath in the way Andreas_D told you.
I am following this question:
How to get rss feeds android?
And I'm using the code from Mathias Lin.
Notice that in the top, it says:
import org.developerworks.android.FeedParser;
import org.developerworks.android.FeedParserFactory;
import org.developerworks.android.Message;
import org.developerworks.android.ParserType;
import org.xmlpull.v1.XmlSerializer;
I managed to find out how to import an external .jar file (the xmlpull one). Now we have the 4 remaining lines, from org.developerworks.android. I managed to find these 4 files online here: https://www.assembla.com/code/churchmobile/subversion/nodes/FeedParser/trunk/src/org/developerworks/android?rev=25 (I don't know if this is the correct way of doing it).
Now I need my Eclipse project to import these external .java files - how do I do this? Now I have red lines underneath these 4 lines because Eclipse can't find them, obviously.
If you right click on the project in the Navigation window in Eclipse there is an 'Import' option. From there it will open a wizard style series of windows that lets you choose what to import and where to import it from. You can also import at different levels of the project (e.g. in the src folder or into a specific package you have created).
I'm trying to create a plug-in to mimic the Eclipse open resource dialog (CTRL+SHIFT+R). I've learned how to create a FilteredItemsSelectionDialog by following the example. But the missing piece is how to fill the dialog with the workspace resources. I found OpenResourceHandler and am trying to duplicate this functionality in my plug-in, so I can step through and see how it works. So I copy the source and rename it to avoid colliding with the real one. The problem is that I cannot import these classes:
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
I tried editing my Manifest but it will not let me import org.eclipse.core (although I can import org.eclipse.core.runtime). So, where do I find these classes and how can import them? And, more importantly, in general how would I find the bundle a given class exists in and import it?
You need to import org.eclipse.core.resources.
In general, you can open the "Plug-ins" view (Window -> Show View -> Other -> Plug-in Development -> Plug-ins). Then, select interesting plug-ins and right click -> Add to Java Search. Then you can use Open Type (Ctrl + Shift + T) to open the class.
Also, in the package explorer, change the Filters to not exclude "External plug-in libraries project". "Link with Editor" can then show you what bundle contains the class you just opened.
I am trying to import:
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
But I am being told these do not exist?
I downloaded:
httpclient-4.0.1.jar and httpmime-4.0.1.jar
... and placed these in the same folder as my .java files that are trying to use httpclient.
Any ideas?
I still cannot get it to work... Within the folder "Libraries" I have: apache-mime4j0.6.jar commons-codec-1.3.jar commons-logging-1.1.1.jar httpclient-4.0.1.jar httpcore-4.0.1.jar httpmime-4.0.1.jar For the java file properties it has: compile classpath runtime classpath boot classpath In each of those, it seems to refer to the jars I have imported. Still getting does not exist. :-(
I have tried to do this in Eclipse too and now those files appear in "Referenced libraries" however it still doesn't work. lol
The two jars you have mentioned need to be placed in the classpath of the project in Netbeans, not in the source directory.
In my Netbeans 6.7.1 on Mac, in the Prjects tab, you cna right click on the project and select Properties. That will bring up the project properties dialog. In there, choose the libraries item from the tree on the left. From there, choose the Add Jar/Folder in the Compile view. To add the jar to your project, use the chooser to locate it and then select it.
EDIT:
I have just downloaded the HTTPClient package and I think I see the problem:
in 4.0.1, the package structure is not as you have it defined. Instead of:
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
use:
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.client.params.HttpMethodParams;
In Eclipse, press Ctrl + Shift + O to organize your imports. This will look for all unknown classes on the classpath and try to import them. You can also place your cursor on a class name and press Ctrl + Shift + M to attempt to import that single class. This is sometimes helpful for class name collision (i.e. if two packages have a HttpClient class, you can click on the desired class).
If the jars are in Referenced Libraries, then they should be on your classpath. You can verify this by right clicking the project and selecting something like Build Path > Configure Build Path, then click the libraries tab.
Also, you probably have build automatically selected by default, but if you don't, you'll need to build your project. You may also want to attempt to clear the build path and re-build it. I've seen my Eclipse get out of synch a few times and this fixed it, albeit somewhat of a fluke.
If you're using Maven, this sort of thing can sometimes occur if you have an incorrect dependency scope (i.e. runtime, or test vs. compile).
For what it's worth, unless you're utilizing the entire package, there is no reason to import an entire package's contents (i.e. import package.*).
It seems that HttpClient has changed his sintaxis from 3 to 4 version... I had same problems that all of you trying to import packages until I found this example:
http://w3mentor.com/learn/java/android-development/android-http-services/example-of-http-get-request-using-httpclient-in-android/
This is sample is Android oriented but works on any Java Application!!! Im using netbeans 6.9.1, httpclient-4.1.1.jar, commons-codec-1.4.jar and commons-logging-1.1.1.jar
Hope you can solve your problems!!!
Had the same problem and i managed to get the solution. Here it is:
1) Download the org.apache.commons.httpclient.jar.zip file from
http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonshttpclientjar.htm
and save it anywhere on your computer.
2) Right click on your NetBeans project and select Properties
3) On Project Properties Categories, select Libraries
4) Click the Add JAR/Folder button
5) Now browse to the file location where you saved your downloaded org.apache....jar.zip
file and click open button.
6) Now the file has been installed, click OK and you are done.
Note that this might require you to restart your netbeans IDE.