Issues while adding jar files to eclipse - java

I'm trying to add some external jar files from the Apache Lucene library to Eclipse but every time i add them to the Classpath it keeps saying i need to attach sources. However i have seen multiple tutorials where they've never say anything about adding source files. They just point at the binaries. I have tried adding them as classpath or as a user library but Eclipse refuses to add them as they are. I'm using Apache Lucene 8.8.1 and Eclipse 2021-03. What do i do wrong and i can't add them?
UPDATE: I'm sending some screenshots for better clarification of what i am doing
photo1
after i make a new project and name it i select next and i choose the Libraries tab
photo2
In the Libraries tab i choose the Classpath and then i select the Add External jars option and i select some jar files from the Lucene folder i downloaded
and when I'm trying to select some .class file from some package i keep encountering this message
photo3

Related

Including the JAR in the same folder to maintain consistency

I have the JAR files in Netbeans as follows:
However, when I check in the Properties section after right clicking on the Netbeans Project, my sqljdbc4.jar is some what different from the other JAR files, I mean it's path is different, since I added it afterwards as shown in the image below:
1) I have got a feeling that, since the path is different, I am not able to connect to SQL Server.
2) Also, when I would have to send the whole project to someone, this relative path won't work I believe. Is there a way, I can insert sqljdbc4.jar inside the src/bundle_includes folder just like the other ones? Please advise. I am using Netbeans 7.4
It seems that when you have added the sqljdbc4.jar it was on the desktop, so Netbeans linked it letting your source code compile, but this don't include the jar into your src/bundle_includes.
You should:
manually copy sqljdbc4.jar into src/bundle_includes
removing the sqljdbc4.jar with bad path from the Compile panel
click Add JAR/Folder and choose src/bundle_includes/sqljdbc4.jar

How do I use PDFBox with Eclipse? Does it package in jar files?

I am writing a Java program in eclipse that will read in a PDF file and analyze lines of the PDF report and spit out statistics about what was read in. In order to read in the PDF file (by extracting the text), I am using PDFbox. The goal of this project is just to automate a manual process.
Two questions:
I've taken some java programming classes but don't have much experience in linking external binary files to eclipse.
Will the PDFbox library I add to eclipse transfer over with the jar file I make? The intention is to email this jar file to a collegue to use in his day to day job to make his life easier. I just want to make sure the packaged jar file keeps the PDFbox library.
How do I add the PDFbox library to eclipse so I can use the library's methods?
You will need to send both the jar you produce (from building your project) and the PDFbox jar. The PDFbox far file must be in the CLASSPATH when you run your application.
Add a jar (for the purpose of building only) as follows: select the project, type ALT-Enter (or right-mouse on the project and select properties), click on "Java Build Path", click the "Add External Jars..." button, browse to the PDFbox jar file, click the "open" button, then click the "OK" button (on the properties window). The PDFBox jar file is now in the build CLASSPATH of your project. See step run concerning the runtime CLASSPATH.
On Mac, For me it worked when I did:
Java Build Path -> Add External Jars ->
And the location was:
/Users/yourname/.m2/repository/org/apache/pdfbox/pdfbox/1.8.x/pdfbox-1.8.x.jar

How to put a jar in classpath in Eclipse? [duplicate]

This question already has answers here:
How to import a jar in Eclipse?
(11 answers)
Closed 6 years ago.
Hi I am n00b in classpath and Ant. While reading the tutorial of GCM for Android I came across a line
Step 1: Copy the gcm.jar file into your application classpath
To write your Android application, first copy the gcm.jar file from
the SDK's gcm-client/dist directory to your application classpath.
I got the gcm.jar from the dist folder. Now how do I put it into my classpath using Eclipse(I think that would be easier)? And where would I make changes if I didnt have Eclipse?
Thnaks
As of rev 17 of the Android Developer Tools, the correct way to add a library jar when.using the tools and Eclipse is to create a directory called libs on the same level as your src and assets directories and then drop the jar in there. Nothing else.required, the tools take care of all the rest for you automatically.
Right click on the project in which you want to put jar file. A window will open like this
Click on the AddExternal Jars there you can give the path to that jar file
First copy your jar file and paste into you Android project's libs folder.
Now right click on newly added (Pasted) jar file and select option
Build Path -> Add to build path
Now you added jar file will get displayed under Referenced Libraries. Again right click on it and select option
Build Path -> Configure Build path
A new window will get appeared.
Select Java Build Path from left menu panel and then select Order and export
Enable check on added jar file.
Now run your project.
More details #
Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)
Right click your project in eclipse, build path -> add external jars.
In your Android Developer Tools , From the SDK Manager, install Extras > Google Cloud Messaging for Android Library . After the installation is complete restart your SDK.Then navigate to sdk\extras\google\gcm\gcm-client\dist .
there will be your gcm.jar file.

Importing an API in Java (eclipse)

I'm trying to import an API that I found online - joda time - into my program.
I've downloaded the files, stuck them in my source folder, but obviously since it isn't integrated into my program they won't work.
I've spent a lot of time googling around for different methods (maybe I'm searching for the wrong thing?) as well as just randomly doing a bunch of different things inside eclipse (I'm developing with eclipse) that include the word "package" or "import", to no avail.
I don't know if it's worth mentioning but my program is being built with the google app engine, and all their stuff is organized in a nice com.xxx.xxxx format, which I think is ultimately what I need to get my stuff into - I just don't know how.
Anyway, sorry if this is a ridiculously trivial question, and thanks in advance to anyone that helps.
You should just have to put the joda-time jar file inside the WEB-INF/lib folder of your project. This folder contains all the libraries that must be delivered with your application, and are automatically added to the build path of your project by Eclipse.
Since you are using Eclipse, you can use the library functions to add in external packages.
Right click on your project, and then choose Build Path --> Configure Build Path.
Click on the Libraries button at the top, and then click the Add External JARs... button.
Select the JAR file in your JODA directory.
If you are using the Eclipse deployment tools, this will automatically package your JAR file in to your web application. If it doesn't do that automatically, add that same JAR file in to your WEB-INF/lib directory (copy it in to your project).

Getting started with Java using Eclipse

I just heard of library for reading/writing excel files without COM, so I figured I'd go check it out.
I downloaded jexcelapi_2_6_12.zip from this page http://sourceforge.net/projects/jexcelapi/files/ but I have no idea how to open it in Eclipse.
I know it's a silly question, but I'm sure it's not the first time someone's asked it, how do I open this in Eclipse in Windows, compile, run and debug it?
Primarily what you need from that zip is the jar which contains the library. You'll still need to actually write a Java app that uses it.
So what you need to do is:
Unzip the file you downloaded
create a new java project
add a lib directory to the project
copy jxl.jar from the zip into your projects lib directory
right click on the jar in eclipse and select "Build Path>Add to build path"
The classes in the library are now available to your project
Next create a new java file in your projects source folder and start coding.
Extract the zip file somewhere, put the jar file in your project's directory somewhere (e.g. under a lib directory) and then right-click on it and select "Add to build path" or something similar.
It's not runnable on its own though - you'll need to write some code in order to debug.
If you want to debug into the source code of the library itself, you'll need to tell Eclipse where the source is - but that's unlikely to be necessary.

Categories