Where I could find the Import file in eclipse - java

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.

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.

IntelliJ - Project tab only shows .gitignore file and not project structure

I have a problem with my IntelliJ project. After adding VCS to my project, the project structure in the "Project" tab is not visible any more.
Here is what it looks like right now:
Other projects work fine and everything is visible (eg. "src" folder, .java files...)
Can someone help?
Thanks
You have deleted the intellij workplace hidden xml files
You'll need to import project again to intellij
Creating a project by importing the sources from Bnd/Bndtools, Eclipse, Flash Builder, Gradle, or Maven
1.If no project is currently open in IntelliJ IDEA, click Import Project on the Welcome screen. Otherwise, select File | New | Project from Existing Sources.
1. In the dialog that opens, select the directory or file which you want to use as a source of import. This may be a directory that contains the corresponding collection of sources or a file that appropriately describes such a collection. (The possible choices are listed right in the dialog.) Click OK.
2. On the first page of the wizard, specify the origin of the sources. (This page is not shown if IntelliJ IDEA has guessed what you are importing.) Select Import project from external model, and select Bnd/Bndtools, Eclipse, Flash Builder, Gradle, or Maven. Click Next.
Ref:https://www.jetbrains.com/help/idea/creating-a-project-by-importing-existing-sources.html

Use classes in jar file in java program in eclipse

I have converted my java code into .jar now i want to use the class in that jar file in another class, so i am unable to do so. Thank you very much for any kind of help!
In Eclipse, right click on your project where you want to use your jar. Select "Properties", there select "Java Build Path". Under "Libraries" you can add the JAR (if you copied it to a lib folder in your project), or select an external JAR (if you don't have it in your lib folder).
When this is done, you can use it in your code. Just use the class, and when a red scribble is underlining your class name, hover over it and select "Import 'Classname' (this.is.your.package)". Alternately, you can let Eclipse auto import the most logical package by pressing "CTRL+Shift+O" (hotkey to auto import)
Add the jar in the new project classpath and then you should be able to use the classes.

Importing class/java files in Eclipse

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!

How to import zip file in netbeans project

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.

Categories

Resources