when I was trying import a zip file in my netbeans project, I get a error in this line
import jericho-html-3.1.src.java.net.htmlparser.jericho.*;
even though I added the zip file Libraries folder.
You probably want to add library to your project so you could call it in your code.
From the line import jericho-html-3.1.src.java.net.htmlparser.jericho.*; I assume that you try to add source code to the project. This will not work.
You need to add a library library and not source code. The library file has .jar extension.
When you download a zip file from http://sourceforge.net/projects/jerichohtml/files/jericho-html/3.1/ The library is in /jericho-html-3.1/dist/ folder of the zip.
For library usage take a look on Sample Programs.
In the Projects window right-click on the name of the project that lacks library -> Properties -> The Project Properties window opens. In Categories tree select "Libraries" node -> On the right side of the Project Properties window press button "Add JAR/Folder" -> Select jars you need.
You also can see MockerTim's short Video How-To.
Related
I have done a reasonable amount of programming in various languages but I am a Java / Netbeans newbie. I have successfully created and run "Hello World" so my Netbeans installation is OK.
I want to write code to control an LED display controller card. I have sample demo code zipped up by the OEM. I am trying to import, run and edit that code. If I can get this running, this will be the starting point of my own code.
The zip files only include library and source files in a directory structure that does not match Netbeans. All of my attempts to import the source and lib files have given fatal errors in Netbeans.
The directory tree has a lib and src branch at the root. The src branch cascades 4 levels to get to the source files.
I figure if I use a different tree structure, I will need to change the import statements in the source file. I'd rather not touch the code until I have it running. I have tried to unzip the project tree directly into the Netbeans directory but that didn't work.
How to import a JAR (Java Archive, the "library" in your case) in Netbeans:
Right click on your project name, in the 'Projects' pane usually located on the left
Click the 'Properties' link from the pop-up menu
Click the 'Libraries' link in the Categories list
Choose 'Add JAR/Folder', browse to your JAR and click OK
If you want Netbeans to create the JAR for the sources you have, do like Stefano says.
You should package the src folder as src.zip with a zip utility and the structure under lib with the java archiver as a jar file.
Now you can define a library in NetBeans and add these files to it (Tools => Libraries => New Library).
For Netbeans to be able to open a project, the folder has to contain some files that Netbeans itself generates when a project is created.
Since you only have src and lib folders available, I think the easiest solution would be to create a new project from Netbeans, so that the creation of those files is automatically managed, and then copying the content of the folders you have in the folders Netbeans will create.
You will also have to tell Netbeans to use those library, and you can do that from you new project's preferences.
Edit
A few more things you can try:
in NB, right click the folder containing the JARs you imported and select "remove", then import them back but selecting the jar files instead of the whole folder;
if you're not already doing so, use the "Clean and build project" button instead of "Build project";
If none of the above solve the issue, try starting from scratch again following these steps:
unzip your OEM files somewhere in your disk;
create a new empty project in NB
copy the files from the src OEM subfolder to src NB project subfolder
in NB, right click Libraries, then add JAR/Folder and select the jar files from the lib OEM subfolder
If this doesn't work either, tell me where I can find the OEM stuff and I'll try it myself :)
ok guys, I'm trying to import the jfugue android port library into a libdx project, but I don't know how to add the jar files from the core project to the android one, since they don't appear as jar in the add jar option in the android build path project.
The jar file you're pointing to is an external jar (you can see it has a full path), so add to the other project using "Add External JARs" button on the "Libraries" tab of the "Java Build Path" page of the project's properties dialog.
Step-1>Just copy the jar files from Quintas_analizer project and paste
them in libs folder of Quintas_analizer-android. Then right click on
the jar files in Quintas_analizer-android and add to build path.
or
Step-1.1 >Another way is that-> right click Quintas_analizer-android
->properties-> Android->Add-> Select the project Quintas_analizer and add.
If Quintas_analizer not shown then go to Quintas_analizer ->
properties -> Android-> Mark the checkbox ->is a library-> Repeat step
1.1
I am working on a Java program, where it will print the stored string in backwards. And I would like to use the ArrayUtils method. So, in order to do that, I have to import org.apache.commons.lang.ArrayUtils; (commons-lang-2.6.jar), which I dont have. And I would like to download it and add it to the library. Once I am in the commons.apache.org page and look for commons-lang-2.6.jar, there are actually 2 sections : Binaries, and Source. Which one should I download and how do I add the library?
"how do I add the library?"
To add a new Library to NetBeans,
do the following (after downloading and extracting the library you need)
If you click Tools -> Library a popup will come up.
There you can add a new library. Click on New Library and give a name the new Library.
Import a library from the ClassPath tab - click Add Jar/Folder, locate and select.
If you want to can also add the javadoc from the JavaDoc tab. You would add the file from the library file you downloaded, called javadoc. This will allow for the javadocs to be seen while editing your code.
Also you can add the sources file form the Sources tab. Import the file named sources
Then right-click on the Libraries folder icon in your project and Add Library
Another option is just add the .jar.
Right-click on the Libraries folder icon in your project and click Add Jar
Locate the .jar file and add it.
the next link contains a jar file which you can import to your project (into libraries):
http://www.java2s.com/Code/JarDownload/apache-commons/apache-commons-lang.jar.zip
basically, the binaries files are compiled code and that is what you want.
I'm new to Java Programming using Eclipse, so would really appreciate your help for this question.
I have doing Java programming both at college and home. At home, I have all my Java classes under a single project-(Java Reference). Now, in college, the java programs are compiled on the lab machines. And I would really like to have all these programs in a single project, on my laptop.
I had recently copied all the .class and .java files from the programs we did in college labs, so I could have them under the "Java Reference" project in my laptop. I copied the .class and .java files under the "bin" and "src" folders of the java project, on my laptop. However, I don't see anyway to import them through Eclipse.
From what I read here, it looks like having an entire project(created somewhere else) could be copied into one place, through the import option, but in my case, I only have the .class and .java files.
First, you don't need the .class files if they are compiled from your .java classes.
To import your files, you need to create an empty Java project. They you either import them one by one (New -> File -> Advanced -> Link file) or directly copy them into their corresponding folder/package and refresh the project.
You can import a bunch of .java files to your existing project without creating a new project. Here are the steps:
Right-click on the Default Package in the Project Manager pane
underneath your project and choose Import
An Import Wizard window will display. Choose File system and select the Next button
You are now prompted to choose a file
Simply browse your folder with .java files in it
Select desired .java files
Click on Finish to finish the import wizard
Check the following webpage for more information:
http://people.cs.uchicago.edu/~kaharris/10200/tutorials/eclipse/Step_04.html
create a new java project in Eclipse and copy .java files to its src directory, if you don't know where those source files should be placed, right click on the root of the project and choose new->class to create a test class and see where its .java file is placed, then put other files with it, in the same directory, you may have to adjust the package in those source files according to the new project directory structure.
if you use external libraries in your code, you have two options: either copy / download jar files or use maven if you use maven you'll have to create the project at maven project in the first place, creating java projects as maven projects are the way to go anyway but that's for another post...
I had the same problem. But What I did is I imported the .java files and then I went to Search->File-> and then changed the package name to whatever package it should belong in this way I fixed a lot of java files which otherwise would require to go to every file and change them manually.
import class folder does not work for me, but add jar worked!
1. put the class folder under the project folder
2. Zip the class folder
3. Highlight project name, click "Project" in the top toolbar, click "Properties", click "Libraries" tab, click "Add External jars".
4. Add the zip file. Done!
I just want to know where does Eclipse store an import file like
import com.codecarpet.fbconnect.FBRequest.
Eclipse doesn't store the imports separately. You can browse the packages using Package Explorer window (mostly found at the left side of window).
Eclipse doesnt store anything for every import. Once you keep adding libraries to your project build path there is a .classpath file that is updated. It contains the list of all the libraries that you project depends on.
The .classpath file looks something like this:
Hover your mouse over FBRequest in the import statement, hold ctrl, a hand appears, click on it.
In package (or project) explorer, the view normally to the left click the two arrow symbol link with editor.
Click on the editor where your class file is, the editor won't look like normal JAVA.
Now you are in the jar file where the class file of the import statement is
Browse up In package (or project) explorer to you find the jar file and right click for properties. There you have a field location and there is were the file is on the file system
Eclipse does not store anything. You tell to Eclipse where to find referenced libraries. Please open project properties (right click on project + properties) and select "Java Build Path" from the list at left, then choose "Libraries" tab
That's plain Java. Eclipse doesn't store anything, you have to put the containing library in your classpath. You can edit your buildpath by right-clicking your project in eclipse --> build path --> edit build path. You can add the needed class-files (or libraries) here.