How to create a patch in IntelliJ IDEA? - java

I've been using IntelliJ IDEA 9.0 Community Edition for some time after years living in Eclipse. One thing seems to be hard to find in it. I'd like to create a patch on some subfolder in my project. In Eclipse it is done using right click, Team, Create Patch.
Does anybody know how to do that in IDEA?

Use the Changes view. In the group by directory mode you can right click on the directory with changes and choose Create Patch from the context menu.

You can do a right click Local History -> Show History and then choose a revision and click on patch button (the second from the left)

From the top corner, click on Git -->patch--> create Patch from Local Changes

In the Local Changes tab or the Repository(SVN)/Log(Git) tab of the Version Control tool window, select a change or changelist you want to create a patch for and click Create Patch from the context menu.
P.S. relevant for all versions

Related

Auto errors detection in IntelliJ IDEA

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.

How to restore shelved changes in Intellij when the shelf tab is not shown?

I tried to use the "shelf" feature for the first time in IntelliJ IDEA today. I shelved all my current changes so that I could work on a quick bugfix, commit it, and come back to my current work afterwards.
When I commited the "shelf" action, IntelliJ created the shelf and I could see it in the tool window. Then it reverted, and reloaded the project.
Now the shelf tab in the Changes tool window does not appear any more.
However in the file system I can see the patch file under .idea/shelf.
Why ? I suspect the problem is that the .idea directory is itself under version control. So when I shelved the changes, it file was included in the shelved changes, and then it was reverted, and IntelliJ is not aware of the shelved changes any more.
I am using Git.
How can I make IntelliJ aware of the patch file in the change tool window ? Or if impossible how can I restore these changes based on the patch file only ?
And how to use this feature in the future without encountering this problem ?
Is it a bad practice to keep the .idea directory in te VCS ?
The answer to the
How can I make IntelliJ aware of the patch file in the change tool
window ?
question was :
Create a bogus shelved change so that the "shelf" tab is available. It will not show if there are currently no shelved changes.
Right click in the "shelf" tab, select "import patch file", pick the previously create patch file. This creates the "shelf"
You can now "unshelf" the changes normally
Finally, I had to manually merge the workspace.xml file. After this, I think I will think about stopping to commit IDE project files to VCS. At least when it is a trivial task to recreate the IDE project from e.g. a checked out Maven project.
If you are ever lose the Shelf tab in a Jetbrains IDE, you may have shelved too large of a file (a 1.81 GB .patch in my case). You can view all of your patches in the Jetbrains shelf by going to:
/.idea/shelf
Delete the really large patch file and restart the IDEA and the Shelf tab reappears on the Git area .
If you don't see your .idea folder in your IDE, follow these steps:
Help > Find Action...
Search "Registry" and click the found action
In the Registry search "dot.idea" and uncheck the checkbox in the Value column for the projectView.hide.dot.idea Key
I had similar issues, but shelving bogus changes did not help (was using WebStorm, but the underlaying IDE is the same). The shelf window did not show up no matter what I did. Even though the shelved changes were created in the .idea/shelf folder. What actually in the end helped was moving/deleting .idea folder under the project completely (good to backup before deletion). And restarting JetBrains IDE.
For anyone (like me) still running into this issue:
The shelf tab is most likely there, but not displayed due to the width of the commit tab.
In the top right of the commit tab there are 3 icons:
arrow down
cogwheel
minimize
On the ARROW DOWN you see all the "hidden" tabs, which includes the tab "Shelf" for me.
Or you make the commit tab wider then you should also see the tabs at the top.

Manually add the LWUIT plugin to netbeans

I have tried going to the plugin download center and I refreshed over 50 times over the course of a week and still i cannot see the LWUIT plugin for Java ME.
Is there a way for me to manually install this plugin without using the plugin download center?
I found out how to do it after a few hours...
go to this link http://www.java2s.com/Code/JarDownload/LWUIT/LWUIT_old.jar.zip , then open the NetBeans IDE and create a new MIDlet project. In the project side bar, go to resources and right-click. On the menu that shows up, click add library. Click edit. Click on add JAR/folder and point to where you extracted the jar file.

How do I add "Android Project" to the File>New>_____ Menu in Eclipse?

I watch all of these Android tutorials online and am getting more and more into Android programming and I find it to be a slight hassle to have to go to File>New>Other>Android>Android Project every time, especially when the person I'm watching has it on theirs.
It would be very helpful if someone could provide me with a way for Android Project (and Android XML File) to be put on that "New" menu.
Thanks
You can add 'Android Project' to the 'New' menu (and customize others) as follows:
Window > Perspective > Customize Perspective... > Tab 'Menu Visibility' > Expand 'File' > Expand 'New' > Tick 'Android Project'
The first one is new android project and the last one is new android xml file.
you can also customize what you want to add thru customize prespective by right clicking the menu area.
If your using eclipse in the toolbar the 8th icon is to Create New Project (its a folder with a a and a + sign sticking out the top of it).
Are you sure you have your eclipse configured properly? I think you need to install ADT and Android SDK first.
If you already have installed them, restart your eclipse to work with it properly.
If not and want to check how and where to install check here.
Following these instructions can enable all these things you want. Feel free to comment.

How to uninstall plugins in Eclipse 3.4.X or higher

The GUI for managing plugins in Eclipse got a bit of an overhaul in version 3.4.0.
This GUI is accessed via the "Software Updates..." option in the Help menu.
The option to remove the selected Mylyn plugin is greyed out. In fact, this is true of virtually every installed plugin. I know that the Mylyn plugins are optional, so why amn't I provided with an option to remove them?
The following text is quoted from the Eclipse help docs:
The Uninstall wizard allows you to review and uninstall items in your configuration. This wizard is shown when you select items and press Uninstall... from the Installed Software page. To uninstall software from your system:
Click Help > About and then click Installation Details... to open a dialog showing pages that provide more detail about your installation.
Click the Installed Software tab to see a list of the software items that you have installed into your system.
Select the items that you wish to uninstall.
Click Uninstall...
The Uninstall Details page will show you a list of the items that will be uninstalled. Expanding each item will show what additional items (if any) will be uninstalled as a result of your choice.
If you change your mind about which items should be uninstalled, you may click Back to see a checkmark list of the items you selected before. You may check and uncheck different items in the list, and click Next when you are ready to continue.
Click Finish to start the uninstall.
Once all of the software is uninstalled successfully, you will be prompted to restart for the Workbench. Click Yes when asked to exit and restart the Workbench for the changes to take effect.
And just to update it for Helios - Eclipse 3.6
Help->Install New Software at the bottom of dialog there is link What is already installed once you click on that you will get list of installed plugins and Uninstal... button
eclipse 3.5(Galieo)
Help>> Install New Software >> Already Installed Plugins >> select Plugins >> Uninstall works charm.
There are distributions of Eclipse that come packaged with certain plugins that can't be mix-and-matched. That is the case with Mylyn, that went from a student's thesis project to an integral part of Eclipse. If you want to actually get rid of Mylyn, you may want to install Eclipse classic instead of the distribution you have, and then install the stuff you need.
The standard Eclipse distributions come with Myln.
BTW, Eclipser 3.5 completely changes all these screens :(
If you are using Windows, make sure you are running Eclipse as administrator. Without administrator privileges, some options may be grayed-out in "Installed Software".
In eclipse Helios (version 3.6), to uninstall a plugin:
Go to Help->Install New Software...
Click on "What is already installed?" link at the bottom right side of the dialog
In the Installed Software tab choose the software you want to uninstall
Click on the "Uninstall..." button at the bottom
Click 'Finish' on the Uninstall Details dialog
Observe the 'Uninstalling Software %' status at the bottom status bar of eclipse
Click 'Restart Now' when prompted to do so.
Eclipse restarts. Choose the workspace. Now when you go again to the Installed Software window , you do not find the uninstalled software.
In Eclipse 3.6 Helios, the interface has changed again. Go to "About Eclipse", and then click the "Installation Details" button in the about box.
While Help → About Eclipse IDE [or wherever it was in the past or will be in the future] → Installation Details → Installed Software → Uninstall... is the official and preferred way there are features/plugins the latter button of which is disabled.
Remember also that there aren't only plugins but features too. In my case I wanted to remove Mylyn and Wild Web Developer from a rather fresh Eclipse IDE for Enterprise Java and Web Developers package. I did the following.
But first a:
DISCLAIMER
Enter ECLIPSE_HOME at your own risk. Mistakes like typos might be in the following, too. I take no responsibility for whatsoever.
Created the directories features.DISABLED and plugins.DISABLED in Eclipse's home dir.
Moved *mylyn* from ECLIPSE_HOME/features to ECLIPSE_HOME/features.DISABLED
Moved *wildwebdeveloper* from ECLIPSE_HOME/features to ECLIPSE_HOME/features.DISABLED
Moved *mylyn* from ECLIPSE_HOME/plugins to ECLIPSE_HOME/plugins.DISABLED
Moved *wildwebdeveloper* from ECLIPSE_HOME/plugins to ECLIPSE_HOME/plugins.DISABLED
After starting Eclipse there were about a dozen "not found" errors in Eclipse's Error Log view. If you double-click on each of them you can see which dependency plugin JAR(s) haven't been found.
Set the Error Log view's filter to just display errors and warnings.
Moved the dependency plugin *.jars mentioned in the errors from ECLIPSE_HOME/plugins.DISABLED back to ECLIPSE_HOME/plugins one by one (with Eclipse restart after each) until no "not found" error appeared in the view any longer. It were nine *mylyn*.jars in the end.:
*.mylyn.commons.core_*
*.mylyn.commons.net_*
*.mylyn.commons.notifications.core_*
*.mylyn.commons.notifications.ui_*
*.mylyn.commons.screenshots.ui_*
*.mylyn.commons.ui_*
*.mylyn.commons.workbench_*
*.mylyn.commons.wikitext.markdown_*
*.mylyn.commons.wikitext.*
Note that this applies to a rather fresh Eclipse 2021-03 (4.19.0) installation. It might be different from one – even patch – version to the other.
Furthermore:
Keep Eclipse's Error Log view open for a while. The underlying OSGi activates bundles (plugins) on the fly if they are referenced from an other bundle (plugin) for the first time. And if one isn't there then...
Check the Error Log view especially after installing new features/plugins. They might rely on plugins/JARs you moved to .DISABLED. If that's the case move the according JAR(s) back to ECLIPSE_HOME/plugins and/or ECLIPSE_HOME/features.
If something doesn't work as it did in the past once in the future remember what you did and ... → Error Log view.
I'm running (a relatively fresh copy of) 3.4.1. I was able to select the same plug-in shown in your screen shot (Mylyn Bridge: Java Development) to get an enabled "Uninstall..." button. I'd suggest getting the latest updates and trying again.
It sure looks like there's no way to do this.
I just had exactly this problem with a fresh download of the Eclipse Java IDE (Ganymede SR2). I didn't want Mylyn, but I didn't want "Eclipse Classic", either, because the download was twice the size, I presume because it includes source.
The apparent solution was to update everything and restart Eclipse, after which the "Uninstall..." button became enabled for the Mylyn plugins. Unfortunately, this only uninstalled the most recent, updated version (3.0.11 IIRC), reverting to the un-uninstallable 3.0.5.
I just don't know what the hell these Eclipse developers are thinking! Removing plug-ins from Eclipse became a pain in the ass since Helios!
I hear you pal... I just went through the whole day trying to figure out as no one seems to give an straight answer like "do this, that, done."
Man I'd rather be programming instead....
Found, in the middle of my evening that it is possible to uninstall pretty much everything. The issue is that the damn thing is hidden in the "HELP->ABOUT". Who would guess after going over and over through the "Help->Install New Software" or "Help->Check for updates" and never finding anything like "remove" or "reinstall" or "force reinstall".
Seriouly, I'd rather go back to 1990 when we had Microsoft, Borland and Watcom.. you picked your platform and you'd be with 1/3 of the world of developers with you.. ok, perhaps Watcom didn't hit that mark but you get the point.
So... to uninstall any plugin from Eclipse Helios (Service Release 1) or Springsource 3.5.2 (or 3.6.1 I 'm using), do this:
close all your projects (just to be on the safe side);
Hit menu "HELP-->ABOUT" (yeah.. help, about);
Hit "Installation Details" button and you get the list with all plugins;
Click on the one you want to remove; hit uninstall;
If want to remove more than one, just apply the change without restart;
Goto to 4) as needed
Finally, restart Eclipse and reinstall what you need !
It was hard to find, but it worked very well for me.

Categories

Resources