How can I import .java file in eclipse IDE? - java

I downloaded Java exercises from exercism.io, I use the Eclipse IDE. I can create new projects in Eclipse and work on them, but can't figure out how to import 'filename.java' and adjust that!
How can I do it? I'm using Ubuntu, do you recommend me to use a different IDE than Eclipse for Java projects?

Go to File -> Import -> Genereal -> FileSystem -> Then select a directory of the file located and then -> select the files you want to import thats it. This is for eclipse Mars

Create a new JavaProject
Create a new class in that java project (located in workspace)
Name the class the same as the .java you want to import
Then simply copy and paste your java code into Eclipse

There is this One way you need to create a new java project in Eclipse then you need to navigate to workspace of Eclipse which is where eclipse stores all java files then locate the project folder you created and then copy-paste all those java files in this project folder.

Related

Import source project in eclipse

I need to import a source Project in eclipse. The project is made by many folder like Classes (that contain .class files), src(that contain .java files) and many others. The source project and the instructions on how to set up eclipse are reported at this link. I tried to follow them but I haven't got anything. I think this is a simple thing but I'm new to eclipse.
My eclipse actual version is eclipse java neon 2.
My OS is ubuntu.
You could choose to create a new Project from the File Options and then select Project from existing sources which choosing the source directory.
Second approach could be to just use File > import Project wizard.

How do you import and use existing libraries in Eclipse?

I'm Visual Studios / C#, you can simply add a reference to a DLL file and then just use that namespace. I'm starting to dig into Android development and want to use the SimpleFTP library. Downloaded the .jar file, went to File --> Import and now I've got SimpleFTP.class and SimpleFTP.java in org\jibble\simpleftp in my Package Explorer.
But if I try to import org.jibble.simpleftp; it says it cannot be resolved. What have I done wrong?
I was hoping I could just start typing as if I had properly imported the library and it'd figure out how to correct my package, but no such luck =[
There are at least three solutions:
If you have the source code, you can place it under your src folder directly in your project.
If you have the source code, you can create an Android Library Project with the source code and connect your Android app projec to the library project.
If you have a JAR file, you can place it in the libs folder of your proejct.
Project -> Properties -> Java Path -> Libraries. There you can add your existing libraries, in several formats (jar, .zip, etc.).
Right click on your project and add build path

How to import existing files into IntelliJ 10 IDE?

I have used Eclipse before. I changed to IntelliJ. Now I am wondering how to import existing files into IntelliJ 10 IDE. In Eclipse I was used to just drag the directory into the src folder, but I cannot do it here.
IDEA doesn't have such feature, you either set up a project on top of the existing sources or you copy files to the existing project externally, using Finder or your favorite file manager.
Actually you can tell IDEA to open a project and when you get prompted with the file explorer you select the eclipse project file. IDEA will then create it's own specific project files and setup the classpath for you. It's pretty nifty.

Import java project into eclipse

I just downloaded a Google App Engine sample Java project. I am trying to import it into eclipse. If I chose file/import/existing projects into workspace, and navigate to the appropriate directory, it doesn't find any projects. I'm speculating this means that dotmatrix is not an Eclipse project. How can I import it?
Thanks.
Project you are trying to import doesn't seem like Eclipse Project.
You can still use this project in Eclipse as Java project by following these steps:
Open Java Perspective in Eclipse.
Right Click in Package explorer pane and select New >> Java Project.
Give appropriate name to your Project and click the option that says "Create project from existing sources."
Select root dir of project downloaded and click finish.
Note: You may need to configure source folders, library and other build paths to complete setup.

How to import java classes from other projects in NetBeans 6.8?

I have just started playing with Java, and I really like the language. I am using the NetBeans IDE, and I find one odd oversight. I can create a new class in a project, but NetBeans doesn't appear to support any way to import an existing class into a project.
I manage to get it done by going to some other project where the desired class already occurs, and then I copy/paste it into the source code folder of the new project, then change the package name at the top of the pasted file to match the package name of the new project.
Is there a nice direct way to do this from the NetBeans interface?
Thanks for any help on this.
In the Projects window you can expand the project that you are working on. Right Click on Libraries and select Add Project.... You will get a dialog allowing you to select another Netbeans Project with the Java classes that you wish to use.
You have to just make the .jar file of that/those java files which you want to use in another project.
right click on file->export->java->.jar then finish.
Now you can use these jar into your another project.
When you build the java project in netbeans it creates a jar file on the dist folder in the current project directory.
You can use this jar file for the other project as a package by adding this as ADD jar in the next project.I have tried this ,i am using my old project jar file for new project development.
Use the 'Clean and build' your project option from the netbeans application, that creates the 'dist' folder which you are looking for (and obviously can't find because you havn't cleaned&buld)
The netbeans itself creates .jar files and you can add the jar file to the current project you are working on.

Categories