unable to install common codec jar file - java

I have downloaded common.codec binary jar file. Now I want to use the class org.apache.commons.codec.binary.Base64. But this folder contains four jar files namely common.codec-1.7.jar,commons-codec-1.7-javadoc.jar, commons-codec-1.7-sources,commons-codec-1.7-tests,commons-codec-1a.7-test-sources. Now which path should I mention in class path? And I tried with all the jar file paths and imported in my program but failed. Please tell me where to place this downloaded jar file and how to use it in my code.

You can use common.codec-1.7.jar if you are using an IDE like
Eclipse:
1.Right-click your Project.
2.Select Properties.
3.On the left-hand side click java build path.
4.Under Compile tab - click Add External Jars button.
Netbeans :
1.Right-click your Project.
2.Select Properties.
3.On the left-hand side click Libraries.
4.Under Compile tab - click Add Jar/Folder button.
or if you directly compiling classes without IDE you can do as #S.R.I mentioned in comment.

Related

Zip Referenced Libraries into Eclipse project

I have no experience with package structure. I added two external libraries (from Joda) to my eclipse project. The code makes use of the libraries with no problems. However, when I export the Archived File and open it on another computer, the libraries are no where to be found. Much sadness.The error looks like a little red exclamation point next to my project in the package explorer. Checkboxes next to the libraries have been checked/applied.
Right click on your project
Navigate to build paths -> configure build path
In order and export tab check whether the library is in the list or not
If it is not selected, tick the Checkbox and click apply
Someone told me that I need to export it as a executable jar.

How do I cross check whether an Imported a jar file is successfully added or not in Eclipse?

I am supposed to replace existiong API with Apache POI 3.16. I have downloaded poi-3.16.jar and have added it in my Eclipse libs folder. How do I check if it is successfully added or not?
Go on configure buildpath and see that jar is there or not with correct path.
right click on project
configure build path go on libraries
now check you jar folder or jar file is present or not.
or you can check by use one of class of this jar like HSSFWorkbook if it is imported means this jar is added successfully otherwise you need to add.
If you import classes from it and attempt using them, does it work or not? There's nothing more to it.
If you replaced an older version of the same lib, remove the old and rebuild the project.
But, above all, do yourself a favor and use Maven or Gradle or any other build tool with dependency management and just add the correct dependency. Manually maintaining the classpath is infernally error prone.
First, open the jar file with any program that you would use to open a zip file. Drill down through the folders until you find a class to represent that jar file.
Note the package plus class name.
Open a "Open Type" message dialog. This is usually at the shortcut, Ctrl + Shift + T, or in the menu at Navigate -> Open Type. Enter the package name plus classname in the dialog. Select the class and it should show the name of the jar file at the bottom.
If Open Type is disabled, you may need to enable it through Window -> Customize Perspective -> Command Groups Availability -> Java Navigation in the "Available command groups"

How to use *.jar file in a Java project?

I'm a complete novice to Java, and I'm stuck in trying to use an external jar library in a Java project I'm working on.
The library is Twitter4J (http://twitter4j.org/), a complex group of files which I can't understand how to include. I'm using Eclipse on Windows. I understood the meaning of CLASSPATH enviroment variable (or well, I think I did), but I can't understand how to link it to the Eclipse enviroment.
This blog post seemed to be what I was looking for: http://jasperpeilee.wordpress.com/2012/01/25/how-to-set-up-twitter4j-quickly-in-your-java-project/
But:
Add twitter4j-core-2.2.5.jar into project for general use.
1) Where should I copy the core file? In the /bin/ folder? Or in a completly unrelated /lib/ folder, as this question in SO stated?
Copy Twitter API property file into your project/bin directory.
2) What is the Twitter API property file?
3) How can I include JavaDoc jar files too? Is it possibile to get them into Elipse?
Any kind of help, even just a link, will be very appreciated!
You probably have a project folder for your Eclipse project. Go ahead and make a lib folder inside of your project folder, in the same directory as src and bin. There's nothing special about the lib folder specifically, it's just a convenient name. Copy the .jar file into your newly created folder. Back in Eclipse, right click your project and click Refresh. The lib folder should pop up, including your JAR! Right click the JAR file and go to Build Path --> Add To Build Path. At this point, any class in the project should be able to use Twitter4J features.
As for the What question, the Twitter API property file contains configuration that is necessary for the Twitter jar to function. The file should probably be located on the classpath of your application.
And the How question, you can attach the javadoc jar file of the Twitter jar to the Twitter jar's classpath entry in Eclipse. Right-click your project and select Properties. Go to the Java Build Path entry and find the Twitter jar under the Libraries tab. If you expand the Twitter jar entry you will see 'JavaDoc location'. You can specify the javadoc jar there.
In Eclipse, right-click your project, select Properties. Now find the entry for Java Build Path and select it. Click the "Libraries" tab if it is not already selected. Click the "Add external JARs..." button. Follow the prompts.

Build java library with resources

I am trying to make android java library, but when I build my project in output jar library placed only java compiled classes, but no resources and assets.
Also my project contains native libraries, I need to include it in jar too.
PS: I have connect my library project to another project.
PS2: I have find out that resources from library project (res, libs) compiles into apk file, but assets not. How to make assets compile too?
To export jar with resource file please follow the below steps.
1) Right Click on Project Folder
2) Then Click on Export
3) Click on Java -> Jar file.
4) It opens a Jar Export Dialog . Please ensure that Exported generated class file and
resource check-box is checked.
5) Then provide the export destination .
6) Finally click on finish button.
In export menu for eclipse, you have a check box asking you for the inclusion of source files

How do you "install" Simple in eclipse?

How do I use simple in eclipse?
Do I add it to the JDK?
http://simple.sourceforge.net
The web site seem to have allot of info on using the methods but little on setting up the library.
I have used C and C++ to set up external libraries before but the Java set up confuses me.
Thank you!
In java world, in order to be able to use third party libraries, what you need to do is to add them to your project/application's CLASSPATH. In case of Simple, its library file is simple-xml-2.4.1.jar that is located inside a folder "jar" within the simple-xml-2.4.1.zip that you would download from Sourceforge.
Download and unzip the
simple-xml-2.4.1 Archive. (ZIP file).
Note that it has a Jar folder that
contains simple-xml-2.4.1.jar - that
is the library eclipse and other IDES
would use to set up the CLASSPATH
Goto your project in project
explorer.
Right-click on the project name and
select "Properties". Alternately, you
can click on the project name and
type "Alt+Enter". A window will
pop-up.
In the window, select "Java Build
Path". You will see several tabs,
including "Source", "Projects" and
"Libraries".
To add simple-xml-2.4.1.jar to your
project, click on the "Libraries"
tab. From there, you can add either
internal jars or external jars. The
"Add External Jar" would be to add a
jar that's on your computer somewhere
. So choose that button, browse to
where simple-xml-2.4.1.jar is located
and make sure to add it to your build
path

Categories

Resources