Is there a way in Eclipse, to see empty parent packages? I have an issue freely viewing/accessing package new.galaxywar.client.resources.images.game that only contains 2 sub-packages:
I tried creating that package again, because I thought that i might not have it in my eclipse project, but it won't let me:
How do I prevent "views from filtering empty parent packages"?
In "Project Explorer" panel, click on the "View Menu" button (represented as a triangle).
Then go to "Customize View..." and deselect "Empty parent packages".
This should do the trick.
While I'm not sure how to perfectly solve the problem, I do know that you can still access the package if you try creating a new file in there, for example package-info.java.
Try doing that by starting to add a Class as usual, but specify the package to be the package you can't seem to access in the Package Explorer.
In recent versions of Eclipse, the steps in the accepted answer have slightly changed:
In Project Explorer panel,click on View Menu button
Then click on Filter
Deselect Empty Parent Packages
Eclipse IDE for Java Developers |
Version: Photon Release (4.8.0)
Build id: 20180619-1200
In Eclipse Version: 2019-03 (4.11.0)
On the Project Explorer tab press the triangle in the upper right corner.
In the menu choose Filters and Customization...
In the Filters and Customization menu unmark Empty packages and Empty parent packages.
Press OK
Now you should see the empty packages.
It's been 6 years since someone answered this question, and in the present day there is way more easiest methods to show hidden parent packages: "View menu" -> "Package presentation" -> "Hierarchical".
View menu of project explorer
Package presentation option
Hierarchical option
Related
I am new to using Eclipse (I just downloaded it).
I began creating a new project, wrote some code, added some packages and classes and closed the project.
Now, I opened it again and I'd like to add a class to a package. So I right-click on that package and the standard popup window appears. But when I now hover over "New ->", there are only three options: "Project", "Example" and "Other". The first time I worked on the project, there were many more options, f.ex. I was able to click on "Class" direct. Right now, I have to select "Other", type "Class" into another window and click "Ok".
Is there any switch or so in the settings that I accidentally enabled that changes the default right-click popup?
I added an image.
Thank you for help!
It seems you are not in the Java perspective: Window > Perspective > Open Perspective > Java
I am new to Java programming language and the IntelliJ IDEA 2017.1 IDE.
I just installed the IDE and I activated all the various inspections but the IDE is unable to detect the errors any time I make a mistake such as omitting a bracket or a semicolon.
This image displays the activated inspections:
This is a screenshot of my code with multiple errors but no detected by the IDE:
Kindly help me solve this problem.
Java file is not analyzed since it's located outside of the source root. You need to either relocate the file or reconfigure your content roots so that it resides under the folder configured as the Sources root.
Sources root is marked in blue in the project view. Here is the example of the properly configured project (notice the class icon is different than on your screenshot):
One more reason could be IntelliJ is running on power saver mode, this could be disabled following way:
File Menu -> Power Saver Mode
This is finally what worked for me! Phew!
My Problem: Whenever I exit Intellij and try to open up an old/existing project, I have trouble getting the builds and execute to work on my localhost. I'm just using localhost.
Here are the steps that finally worked on my localhost environment:
1. Go to Project Structure and Select Project
a. Set the SDK to 10 (“Java Version 10.0.2”) or whatever you are using.
b. (I think this was the main step I was missing) Set the project compiler output to point to where I want the compiled output to sit: C:\Users\kbala\OneDrive - MatrixCare\SoftWLearnings\Javamyfun\NewHelloWorld\out
c. Project Language Level: I chose “SDK Default”
2. Go to Project Structure and Select Modules
a. Click on src (this is where my source code sits).
b. Then, Click on the “Sources” folder icon on the top. This adds src to the “Source folders” on the right. You will see the color change to Blue
c. Click ok.
3. Then, click on “Add Configuration” (top right corner of Intellij)
a. Select + at the top left hand corner.
b. Select “Application”
c. Change the name to “Main”
d. Now click on the Ellipsis (three dots) in “Main Class”. You should now see your Main Class. Select it.
e. You should now see the execute arrow at that top right of Intellij. And you should see the build icon (Hammer).
This should work!
If you use a build system (Maven, Gradle, etc.):
Open its panel in IntelliJ, then click the reimport button. For Gradle, this button looks like a sync icon and its hovertext says "Reload All Gradle Projects".
Why it works:
Since the build system is in charge of compiling your code, it knows which files are source code. It would be a waste of computing power to look for missing semicolons in a compiled binary file, so IntelliJ won't try to find errors until it knows the file is source code.
Most build systems, Maven and Gradle included, are also dependency managers. When you write code that uses libraries or depends on a different module, IntelliJ needs to be able to understand the dependency to tell you whether your code makes sense, or whether you made a mistake like forgetting an import statement or passing the wrong type of argument into a library function. When IntelliJ doesn't understand your dependencies, it displays all your uses of imported code in red text.
I was getting the same issue, I just clicked on the re-import button on the maven panel and it solved the problem .
I had the same issue and here it is how I solved it:
Some files where ignored and I Unignored them. To do this go to Maven tab on the right panel -> right click on each project that is in grey color and click Unignore projects.
I'll add an another reason for it. For me it was Reader mode enabled. I was not even been aware of its existence. Can be disabled in Settings -> Editor -> Reader mode.
In my case was a maven option!
When you open the proyect in intellij, it create a notification.
I have a package structure: com.report.domain.model
I would like to change it to com.reporting.domain.model. When I select Refactor → Rename on package com.report.domain.model, I only see an option to rename 'model'. I have tried switching between Project view and Package, but to no avail. I know how to make this change in Eclipse via Navigator view, but how can I do the same in IntelliJ IDEA?
In the Project Window, click on the Gears icon in the title bar and deselect "Compact Empty Middle Packages". Then you can separately select the report package and rename it.
See also: http://www.jetbrains.com/idea/webhelp/project-tool-window.html#d242351e401
N.B. As of IntelliJ IDEA 2016.3, there is a bug in the menu and when the option is selected, it has a different label "Hide Empty Middle Packages", see https://youtrack.jetbrains.com/issue/IDEA-168362.
To change the full package name:
User jkovacs has already answered this, but I'm going to cover this in a bit more detail. For example, if you want to change com.example.app to my.awesome.game, then:
In your Project pane, click on the little gear icon ()
Uncheck / de-select the Compact Empty Middle Packages option:
Your package directory will now be broken up in individual directories.
Individually select each directory you want to rename, and:
Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Allow a minute to let Android Studio update all changes
Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All:
Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:
Done! Anyway, Android Studio needs to make this process a little simpler.
I have a huge Maven multi-module project. With similar structure
parentA
- subA1
- subA3
- subA3
- subA2
parentB
- subB1
- subB2
etc
The problem is, that parentA and subA1 does not contains any code inside it, but I can still see them in project explorer. But I would like to hide them or organize in tree hierarchy like in an explorer. Right now there are over 30 projects and just 20 of them contains Java code. Others simply contains others modules references. I see all 30 projects in plain form in project explorer.
The first idea - was using working set, but I can't include working set in another working set. What is the common practice to handle this issue for eclipse users
go:
Windows -> Preferences -> Maven -> Hide folders of physically nested modules
and re-import your project.
We can also use working sets.
Choose Top level Elements as 'Working Sets' from Package Explorer / Project Explorer view.
Configure "Working Sets" to manage your projects. Move the Parent project to a different working set and child project in different working sets.
In Project Explorer, there's a down arrow, if you hover over it, it shows "View Menu".
Click on it, Project Presentation -> Hierarchical
Try using Projects View. It does it for me in these kind of situations.
Also, you can put filters to exclude certain projects in Package Explorer or other views that you prefer like this: go to PackageExplorer, select View Menu - Filters, check Name filter Patterns and enter the names of the projects you want to hide, separated by commas.
In other views, instead of View Menu - Filters is View Menu - Customize View.
You can find a tutorial here but instead selecting Closed Projects enter the name of the projects as I mentioned above.
As for the tree view I don't think you achieve that because in Eclipse there is no notion of sub-project. Have a look here.
From the Package Explorer view select filter from 'view menu'. Then select filters, and exclude Non-java projects.
On the package explorer window:
-> Select the three dots menu -> Then Package Presentation -> And then change from Flat to "Hierarchical"
And you are done :D
Change project view image
Wouldn't it be nice to just do a keystroke and have eclipse organize all imports in all java classes instead of just the one you are looking at? Is this possible? Is there a keystroke for it?
Select the project in the package explorer and press Ctrl + Shift + O (same keystroke as the single class version). Should work for packages, etc.
You can edit the clean up options on save to make it organize imports. That way all of your imports will always be organized.
In eclipse 3.4 just go into Window - Preferences. In the tree view look under Java -- Editor -- Save Actions.
This is how I keep my imports organized all of the time.
For Eclipse Helios, open the "Project Explorer" view, clic right on your src folder, go under the source menu, and clic "organize imports" that should work for all your project.
or just hit the combination Ctrl + Shift + O on the src folder.
If you want to run save actions against a whole project you can right click on the project, then choose Source and then Clean Up...
I have Leadbolt ads in my Android app. On every Leadbolt version, Leadbolt force me to re-update the name of the java import. For example, in my app it was :
import com.kwswsuyruzouggmtbzxb.*
Then on the update they gave me a new package with the name:
import com.izwevyqazy.*
And therefore, I have to make a change from the older name to the newer name on around 20 or more of java source code files. So, what I did is to re-organize the imports using this way in Eclipse I.D.E.:
Select in your application, the package name, the one directly under the folder "src" in your project folder.
Right click the package name and select "Organize Imports"
Please don't forget to change the names too in the AndroidManifest.xml; otherwise, your app will crash.
For mac you can use Cmd + Shift + O. Alternatively, you can do it through the menu: Source -> Optimize Imports
You can run this on individual files, or for each source folder. The option is greyed out if you try it at the project level of the project explorer. So you may have to do it a couple time if you have a bunch of modules and source folders. :)