How do i import a source code into eclipse - java

I have a folder called src and somehow i have to import it in to eclipse to work with the code.
This is how it comes from github:
I've tried to put the src folder in an existing project still cant read it. What should i do?
Im not so familiar with java :/
The final jar file stuctures should look like this:
(its a bukkit plugin)

File -> Import -> Maven -> Existing Maven Projects
And point it to the root folder of the projects (the one containing the top pom.xml).
You'll need a Maven plugin for Eclipse for this.

In Eclipse: right click on src -> Build Path -> Use as Source Folder

Related

How can I import this java project with no src folder into eclipse?

How can I import the java project shown in the picture below into eclipse, since there is no src folder in it.
Eclipse doesn't depend on source folders being called 'src'. You can import any directory as a "project" in eclipse and then configure the source folders from the right click -> properties -> java build path.
However, if that directory doesn't actually contain any source code, the question is if you're trying to use the classes/jars contained within. Then you need to add those classes/jars to your classpath.

import a web project using ant build file

I have a web project from TrortoiseSVN. When I import this project into workspace using ANT build.xml it become a simple java project. It is not recognize the web-inf and web root folder.
How I import this project into workspace?
You can make an empty project like you want, and then copy the file to the project which you created. And then enter "F5" to see it or not success!
For Juno, do File->New->Other, then select File -> New -> Other, and at the New dialog, select Java Project from Existing Ant Buildfile
try importing the project in a different way, maybe import it as an existing project into eclipse

How to import and run ivy+ant project in eclipse juno

this is my first use of ivy+ant and after building the project from command line, i want to import it into eclipse juno.
the project folder (trunk) contains the following folders/files:
build
dist
src
WebContent
build.properties
build.xml
ivy.settings.xml
ivy.xml
i tried to import the trunk folder that contains the above files/folder using import existing projects into workspace, but i get the error that no projects found.
pleases advise how to import this project.
UPDATE: i tried to configure the project for eclipse before importing using the following command:
ant eclipse-default
but i get the following error:
Target "eclipse-default" does not exist in the project
UPDATE 2:
i was able to import the project in eclipse as follows
File > New > Other > Java Project From Existing Ant Buildfile
but when trying to run the project on server, i can't find run on server in the run options, please advise.
You may try this:
Install IvyDE from http://www.apache.org/dist/ant/ivyde/updatesite (ref: http://ant.apache.org/ivy/ivyde/download.cgi)
IvyDE may not recognize your setting and properties file. At Window -> Preference -> Ivy -> Settings, check reload the setting on demand, add Ivy setting path ivysettings.xml or your Ivy setting file, Property files build.properties or your Ant properties file.
Add new Java project you want to work on, point the path to your project.
At the new project wizard, Libraries tab -> Add Library -> IvyDE Managed Dependencies.
You can not import a project of you do not have the eclipse project information in your code.
Either create a new eclipse project from existing source.
Or a new java project from ant buildfile (your update 2).
For running need configuration of server (hard to know what youneed there), you may need to create new server (preference/server/run time environnement) (or from view server, right click "new")

Cannot import spring mvc project property into eclipse

I am trying to import the project at http://www.javaworld.com/javaworld/jw-04-2009/jw-springmvc-cms-src.zip into eclipse.
I do File -> New -> Project.. -> Java Project From Existing Ant Buildfile. I give the path of the build.xml of the project.
It imports the project into eclipse and shows the src and test folders. However, it does not show the WEB-INF, css etc. folders. Why? How can they also be viewed in the project structure in Eclipse.
You should try creating "by hand" the missing folders into your newly created project, then you can use Import -> File system to add the missing files into the respective folders...

Wrong package name when using automatically added imports in Eclipse

I have several Maven projects converted into one Eclipse workspace. When I edit the code under Eclipse, I sometimes use CTRL+SHIFT+M combination of keys to automatically add imports to the classes from a project in my workspace. But somehow they are added like this:
import src.main.java.com.mycompany;
while to real package I wanted to import is com.mycompany.
This has to be some configuration in Eclipse to fix this but I'm confused. However, this issue is very annoying.
EDIT:
I've forgotten to mention that Eclipse files were generated using mvn eclipse:eclipse command.
Under Eclipse project seems to be configured properly. Its source folders set like this:
src/test/java
src/test/resources
src/main/java
src/main/resources
And everything under Eclipse works properly except the situation when I press CTRL+SHIFT+M keys
The standard source folder for Java projects is
./src
For imported maven projects, simply remove this folder from the list of source folders at the build path settigs. The correct source folder is
./src/main/java
In eclipse;
Remove the existing source folders first.
-right click -> menu -> build path -> remove from build path
then
Right click on the source folder.
build path -> use as source folder.
Seems like your settings are pointing to the parent of the source folder so src is recognized as package by eclipse.
It's because eclipse is not aware of the convention over configuration filestructure Maven is following. Install the M2Eclipse plugin and File > New > Other > Maven Project for new projects or for existing ones right click on your imported project on Package Explorer > Maven > Enable Dependency Management. Once successfully done, on the Package Explorer you would see your project nicely gathered following the Maven conventonal filestructure like src/main/java, src/main/resources, src/test/java and from then on you'll start seeing your package structure hierarchy like com.mysite.myproject..
First remove it. Then add it back using right click on package->build path->configure build path-> Source->Add Folder and add the entire /src/main/java tree
You've got the wrong source folders in your build path, and it's a wonder that anything works at all.
You can use either the maven-eclipse-plugin or M2Eclipse to automate getting this right, or you can manually fix the build path to call our your actual source folders, not their great-grandparents.
Non of the above worked for me. Finally I just changed the name of the scr folder to scr-java and this removed the package structure with scr as root package.

Categories

Resources