Eclipse Folder Structure - java

my Workspace on Eclipse is currently set-up so that it has a Folder Structure, like this:
I made it like that on accident but I prefer to use it and I need to make a new Workspace soon, because I don't want to delete all my projects.
Does anyone know how to make Eclipse be set-up like this with a folder structure instead of like this:

Click the small down arrow (triangle) at the top right of the view and select 'Package Presentation > Hierarchical' in the menu that appears.

Related

Intellij right-click 'New' is not showing 'Class'

Related: IntelliJ does not show 'Class' when we right click and select 'New'
In the above accepted answer, it says the "New" does not give the option for Java Class because it was not the source root (blue directory).
However, as you can see, even though where I am right-clicking is source root, indicated by blue box, it is not giving me the option for Java Class
Any idea why?
This directory is imported from git so it did not follow the usual "Create Project" for java directly from Intellij
You are right clicking in the wrong spot -- youre "too high" up the tree. Go to where you code is (as in the package under "src") and try it there and you will see the option for a New Class.
EDIT: You don't need to be in the source root. You need to be in the source directories themselves. The blue dot I believe is a git status indicator. What you want is an entirely blue folder.
Go down under "src". Likely under "src" then "main" then "java", and you're there (that's blue for me) and then you will see your package folders. Below those are where you likely want to be adding classes.
As many mentioned above you can right click on the folder you would like it in. In your case:
If you push Alt+1, it might be easier for you to right click
src > New Java Class
Alternatively you can push:
Alt+1 (Project View)
Alt+Ins
or
Ctrl+Alt+Ins
1) Right click on src
2) Click New > package
3) Name your package and press OK
4) Right click the newly made package
5) New > Java Class
If the folder where we are trying to create the class is not marked as source or test then the option is not available.
Right click the project and go to project structure then under project settings -> Modules, Select the folder where you wanted to create class and mark as Source or Test appropriately and then click apply and ok.
Now you will see the change of color of the folder/package(Sources->Blue, Test->Green) and you will get the option to create the class.
This worked for me.
I know this is an old thread, but it happened to me because my gradle files were not synchronized. So if you are within a team working on same project and face this issue, make sure to run gradle sync.
You should go inside java project then you can create java class.

Eclipse showing java project src folder view as all packages and subpackages

Not sure how to really ask this question since I don't know what everything is called but I'll try to do the best I can.
So as I was cleaning up my classes. I right clicked my project and selected refresh. Then all of a sudden my project view changed, the src folder shows everything as packages and '.' separated subpackages. And all my code package declarations seems now to be undiscoverable.
I've attached a photo, hopefully you can petter understand this...How can I fix this to have the correct directory view/structure.
Edit:
Here is what I have linked to my JAVA build path
I don't understand what is happening? How can all of a sudden my project screw up like it has? Any help will be much appreciated
Look at the 'Java Build Path' in the project 'Properties' and check that you have the correct 'Source' folders. It looks like you may have just 'src' as a source folder when you should have 'src/main/java', 'src/test/java'...
I was able to fix this by maven>update project, then just refresh...
In addition to the previous answer you also may use empty package filter:
At the top-right of the Package Explorer view, there's a downward-pointing triangle. If you hover your mouse pointer over it you'll see View Menu.
Click the View Menu, select Filters, put a check next to Empty Packages, then click OK.
Same way you could tune other options for Package explorer such as file types to show etc.
Well, it seems pretty clear that your hierarchy does not match the name of your package, so just fix your hierarchy. It will be easier if you switch to the hierarchical view of the packages. To do so, go to Package explorer, View menu (arrow icon pointing to the bottom), Package presentation, Hierarchical.
The following worked for me:
Right Click on src (which is shown like empty package in my project) -> Build Path -> Use As Source Folder

How to rename/refactor a whole libgdx/java project in eclipse

Ive made a game with the libgdx framework in eclipse and I want to copy this project in the same workspace so I can make changes to this whilst viewing the original code.
I have tried refactoring before but it all messed up somehow and I ended up having to start a new project and copying over every class ( took a while )
Is there a way to rename the projects in a better way or how do you rename them properly as I obviously did something wrong.
In package explorer
Right click on project
Click Refactor > Rename or press Alt+Shift+R
Give new name

How to insert images using labels in NetBeans IDE, Java?

I'm making a virtual mall using NetBeans IDE 7.3.1
I inserted images using the following steps:
Drag and drop label onto frame
Go to label properties
Click on ellipsis of 'icon' option
Import to project, select desired image
Resize or reposition it accordingly.
Then, I saved the project, copied the project folder into a pendrive, tried to 'Open Project' in mate's laptop, using the same Java Netbeans IDE version.
When I tried to open the frames, they displayed empty labels, without images.
What went wrong?
Make sure that you have the image you want in the src folder of your project.
NetBeansProjects->YourProject->src->YourRequiredImage.
Now use the label properties and set icon from this folder.
Copy entire project folder to your friend's system and run. It should work.
Maybe the image was not imported properly.
Have you cross-verified that the image file was present in Netbeans Project Folder (maybe in the 'src' folder of your project or any other folder inside your project folder)?
Keep in mind always, If you want to give your app to someone else, So give your images too. And keep those images into the folder you have stored in.
Instead of using an external image, just create a resources folder in your src folder, and add the image to the folder. Then use select image from project. And select the folder from the drop-down and select the image.
That because your images are not included in the mentioned path ( path has been changed ). So always better to put your images in a Different PACKAGE under your project.

not possible to make normal package in eclipse

In Eclipse I have two projects with the same package structure.
In one of them by mistake i delete the package.
When i Want to make structure I lost again I see this:
not this :
what is wrong ?
Make sure the folder is in your build path.
Try right clicking it and choose "Build Path" > "Include".
You may be browsing in the Navigator view, not the Package Explorer view.

Categories