Eclipse doesns't show project explorer properly - java

I'm using eclipse neon. I have created a maven project and create a package com.prueba.account and then I have created many packages inside.
But eclipse shows me all packages as an independent project and without the full path like in the image. Notice that checking package is inside com.prueba.account

Just Click on the Drop Down in Project explorer. All you need is to change Package presentation from Hierarchical to Flat.
Hope it helps !!!!

First of all, welcome to Stack Overflow Gary.
Then to extend on Adyas Answer:
In Eclipse there are two ways to display the package-structure.
Hierarchical :
And Flat:
I personally find the Hierarchical view way more convenient, for when you're working on a bigger project, you often get really long package names which, when in Flat view, might clutter the whole window.
But in the end, it's up to your personal taste.
The way to change between this two modes is to click on the down arrow icon at the top of the Project Explorer and under Package Presentation you can choose between the two.

Related

View Package Dependencies in Eclipse

Is there any way to view package dependencies in Eclipse? I seem to remember a long time ago that it was possible. I have a packageX and want to see what packages refer to it. Ie packageY references it, but not packageZ.
There seem to be some outdated plugins out there, for example Java Dependency Viewer, but the comments for the plugin say 'don't bother'.
If you mean a java package, there is a possibility: You right-click the package in the project explorer, select References → Workspace and get ... a list of almost no results.
Then you go into the search menu (the small triangle ▿ at the top right border of the search view), select "filters" and uncheck the "imports" box. Then all references to your package within your workspace should appear in the view.

Eclipse is creating two class files

When I create a new class inside a package for some reason it creates two class files: one inside of the package and one out of it. I wanted to know why this is happening? Also, at times, Eclipse are kind of "hiding" some of my classes, so that they do not appear in the project explorer, although when you create a new class file with the same name of the class that disappeared, it says the class already exists...
When I refresh (F5) the package, these problems are sort of solved. But they happen again when I create a new class or when I restart Eclipse. So I wanted a different solution from keep pressing F5 everytime...
So I had this same problem and it may be for the same reason. The problem can be because you are creating the .java files in the Project Explorer window. Close this window. Then, go to Window -> Show View -> Package Explorer. Then create your .java files there. The issue is that the Project Explorer window looks EXACTLY the same way as the Package Explorer.
#Rammohan's answer helped me but I can't vote it up or apparently add a comment because of low reputation. Being new to Eclipse I didn't get what he meant at first, so wanted to add a little detail for other people.
From the top menu it's Window -> Perspective -> Open Perspective -> Java.
I had unwittingly switched to the Debug perspective and had the double-creation problem happening in src/test/java (but not in src/main/java, still don't get why). Switching to the Java perspective cleared it right up.
I also had same problem with eclipse. This issue is resolved after changing Perspective mode from "Debug" to "Java". Two same class files appear when Eclipse Perspective is in "Debug" mode. In "Java" perspective, this issue is resolved.
Hope this helps if someone facing same issue.

Refactoring package name breaks entire app

I am trying to refactor my package using Eclipse
org.sheehan.activity
to
org.sheehan.stocks.activity
For some reason my project just blows up when I do this and R doesn't get regenerated. How can I refactor properly?
UPDATE:
I updated my Android Manifest to reflect the change. R still doesn't get regenerated. Even after a clean. The compiler is complaining about org.sheehan.activity.R
I resolved by:
Android Tools > Rename Package Application
If you renamed properly, all your references across your project should have gotten updated. After doing this, clean your project by going to Project > Clean. This should fix it.
Fixing missing reference to R in eclipse:
Refactor -> Rename`
Build -> Clean
Android Tools -> Fix Project Properties
select the base package of your project in the eclipse package explorer, press F2 (Rename), in the rename dialog: SELECT ALL the checkboxes.:
That should do it
The package name doesn't update in the XML files. Specifically your manifest which needs to know the base package.
For more advanced imports and refactors, literally closing the Eclipse IDE can refresh a cache that causes random errors like "End position lies outside document range" or the "what once worked now doesn't hair puller outter errors."
Signs you should close Eclipse when trying to rename things are:
When you import a project, do some refactoring (like trying to change the package name), then delete the project and try again, you will see immediate R.java errors when you didn't before
When you are importing projects that have manually generated R.java files that have custom imports like "com.ns.proj.R" and don't see the name update in Preview
The box that asks if you want to "Rename subpackages" is checked unexpectedly
the code in the "Preview>>" looks as if it's been complied before instead of black and white code with the proper names replaced
you get XML errors in the manifest activity name like this
android:name="com.ns.proj.CustomCocom.ns.proj.CustomControlse="#android:style/Theme.Light.NoTitleBar"
when it should be
android:name="com.ns.proj.CustomControls"
android:style="Theme.Light.NoTitleBar"
There are too many to name obviously, however this is as important as "keep your eye on the ball" in sports. Something that is so easy to forget, yet things like these apply to other software programs like Dreamweaver (e.g. when you use the Dreamweaver "Put" option instead of FTP dragging with FileZilla and you notice your domain isn't updating your changes online). I called Adobe when I first started as a developer 8 years ago because I knew I wasn't doing anything wrong. They said sometimes the generated files to perform the action get corrupted...in other words, IDE's have bugs too!
In general, close the IDE before you off yourself...it could save your life!
Right click in your Project, go to
Android Tools > Rename Package Application
Sometimes if Project > Clean doesn´t work, so Delete /gen and /bin folders of your project.

Project Directory Structure Problem in Eclipse

I am facing this weird problem ..When i checked out project from svn my whole project was in directory kind of structure
ie. my package was like (folder inside another folder)
MainProject
+
+
+++project_1_name
++++++++src
++++++++++++com
++++++++++++++companyname
++++++++++++++++++ClassName
+
+++project_2_name
++++++++src
++++++++++++com
++++++++++++++companyname
++++++++++++++++++ClassName
but i want it to be like
MainProject
+
project_1_name
+++++src.com.companyname.className
project_2_name
+++++src.com.companyname.className
when i am importing a particular sub project from the main project separately on my workspace then the project is appearing as package structure as i see..I am using eclipse for the first time ..Kindly pardon me for asking some thing stupid like this ..But please help me
thanks in advance
The structure/folder hierarchy is as expected, a java package is a folder.
In Eclipse, Package Explorer, click on a small arrow-like icon pointing downwards and select Package Presentation 'Flat' or 'Hierarchical'.
Possibly you would like to have 'Flat'.
Do you mean you want the Package Explorer view instead of the Navigator view?
Window > Show View > Package Explorer
Or maybe you want the Project Explorer view:
Window > Show View > Project Explorer
Either of those views has a "flat" and a "hierarchical" package style. The "flat" package style sounds like what you want.
When you import projects from SVN, after selecting the base url, you should check the "find projects in the children of the selected resource" box.

How to import existing project into Workplace in Eclipse?

I am trying to follow Eclipse instructions to create a Hello World SWT application. I have the following instruction:
Import the SWT project from the main
menu via File > Import..., and select
Existing Projects into Workspace.
Specify the archive file you
downloaded and click Finish. This will
create the org.eclipse.swt project
which we will need to compile and run
the application.
I have troubles with that. In the "File" menu I see "Import...". When I click the "Import...", I do not see "Existing Project into Workspace". Instead of that I see "Select an import source:" after which I see a text field. After that I see a field with the following folders: General, CVS, Run/Debug, Tasks, Team, XML.
Can anybody help me with that, pleas?
You need to expand General.
If you expand the 'General' node (folder) you will see 'Existing projects into workspace' as an option. Select that and click on Next.
Eclipse has the wonderful search functionality on most of its important screens. Even if you don't know where exactly it is, you can type it and it appears. In this case type "Existing" into the text field above the list and you'll see what you are looking for.

Categories