Eclipse won't update after adding project to workspace folder - java

I added a Java project (containing one default package with 2 classes) to my folder which I declare as my workspace in Eclipse. But when I launch Eclipse, it does not add this project in the package explorer. What can I do to solve this problem?

You can't copy files or folders to your workspace folder, you have to import the project into Eclipse:
From the main menu bar, select command link File > Import.... The Import wizard opens.
Select General > Existing Project into Workspace and click Next.
Choose either Select root directory or Select archive file and click the associated Browse to locate the directory or file containing the projects.
Under Projects select the project or projects which you would like to import.
Click Finish to start the import.

Click with right button on the folder containing sources and select use as source folder

Related

Exclude files from JAR build with Eclipse

I have a folder at the root of my Eclipse Java project to hold configuration files for the application and log4j2. The only way I can get the in IDE build to work is to add that folder to the Java Build Path of the project.
I need to exclude either this folder or the files therein from the JAR file export. This will allow it to look in the same folder for those 2 configuration files.
Right click on the project folder in the Eclipse Package Explorer.
Select "Build Path", then, "Configure Build Path".
Go to the "Source" tab that appears. (You should be automatically selecting "Java Build Path" in the left hand side of the popup window)
Open the folder for your project, and click on "Excluded", then click "Edit" on the right hand side.
From this window, you should be able to click "Add..." in the exclusion patterns. The dialogue box should have a "Browse" button that will allow you to exclude specific classes or packages. The input also accepts wildcards.
You could pack your dependencies project into jar(wihout excluded files). Then pack as previously.

Folders mess up after import project into Eclipse

I have a JAVA project contains multiple folders, and after I imported them into Eclipse, the folders messed up like below.
How can I put these "src/main/java" folders under the "src" one in eclipse, these folders are well-organized on my file system.
eclipse detects project type and it adds directory structure in .classpath and .project when you import new project,
if you want to see raw structure, switch to navigator view
windows > show view > navigator

Eclipse Package Explorer not matching physical folder structure

Newbie question
I have downloaded a project from git repository using Eclipse (Import-> Clone URI).
It created a folder in my local MyDocuments git folder and I can also see the project in the Eclipse's Package Explorer.
For some reason, for any source file, say HelloWorld.java which I see inside the MyDocuments git project folder, I do not see HelloWorld.java in Eclipse's package explorer. I have changed perspective to java/javaee/java browsing etc.
Is there some setting/perspective in Eclipse where I can see all the source files?
After successful cloning git repository inside eclipse, you need to import these project inside eclipse.
Click Windows > Show view > Other then select Git repositories view. Right click on Working directory then select Import project.

how to add a package to eclipse which can be imported using import statement?

i downloaded RSyntaxTextArea package from http://sourceforge.net/projects/rsyntaxtextarea/‎, now i want to import it into my eclipse project by using import statement, how to do this?
Add downloaded package/jar to your project's build path. Right Click on project, Properties-> Java Buld Path-> Libraries-> Add external jars -> browse and select downloaded jar-> press ok button. That's it.
For importing a project in eclipse, do following:-
Open perspective Package explorer (Best perspective for java)
Right click on the blank area > Select import > Select existing project into work space > Click import and you are done.
For adding as a jar,
Copy the jar file into your project's libs folder
Select project > Properites > Java Build Path > Libraries > Add jars > Navigate to your project's libs folder > Select the jar file > Click ok and you are done.

Importing projects with Eclipse so new stuff I add will go to the source directory as well

When I do File -> Import, General (from the pop-up window)->Existing Projects into Workspace, I can browse to where all my projects are and import them so my Eclipse workspace folder with its .metadata is in a separate location from my source directory.
The problem is, if I add a new project or even add a new file within an existent project, the new files get made in my Eclipse workspace folder, not over where the other code lives.
How do I tell Eclipse to put new code in the source directory, not in the workspace directory? When importing, I did not check the checkboxes "Copy projects into workspace" or "Add project to working sets" (Add project to working sets requires the selection of working sets, which I don't know about).
It depends on the kind of project you are creating. For example, a "Project" type project that just contains dumb files lets you uncheck the "Use default location" option and will actually be created in whatever directory you give it.
Java projects, on the other hand force you to create them in the workspace.
For project types that eclipse will only create in the workspace you can use the following workaround.
Create the project in your workspace.
Delete the project from eclipse without deleting the files on disk.
Use your OS tools to move the project folder where you want it.
Back in eclipse: File -> Import -> Existing Projects into Workspace
Browse to folder containing your relocated project.
Make sure to uncheck the "Copy projects into workspace" option

Categories

Resources