Netbeans IDE - Automatic Suggestion while typing - java

hi i am using netbeans 7 IDE for java programming , and i am acutally a C# programmer and in visual studio whenever i type anything it displays a dropdown menu with suggestions , i want that to be enabled on netbeans IDE without having to press CTRL + Space to show the dropdown menu
thanks in advance .

By default, Netbeans gives suggestion only when you put a period (i.e. for class and object fields and methods).
However, you can customize auto-completion by going to
Tools > Options > Editor > Code Completion
Choose whatever configuration works best for you.
Hope this help!

Make sure in the Code Assistance (e.g., Tools → Options → C/C++ → Code Assistance), in case of C/C++, you added your compiler's include directories.
You can find the compiler you are using in Project Properties → Build → X Compiler

a common response to your answer suggesting the automatic code completion in netbeans IDE is as follows,
Goto Tools
Select options
then click on code completion
Select neccessary checkboxes you want and then click on apply then click ok.

Do this
Goto Tools
Select options
then click on code completion
Go to All Languages > Java > select all
select "Auto popup on typing any Java identifier Part"
select "SubWord completion"
select "Guess Filled method arguments"

Apart from what was already mentioned, you can also do the following to always have suggestions:
Tools > Options > Editor > In Languages select Java > Auto Popup triggers for Java paste the following: .#(#&$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

Related

Eclipse Organize Imports Shortcut (Ctrl+Shift+O) is not working

Eclipse used to import missing packages when I press Ctrl+Shift+O.
The shortcut key has stopped working when used in Java files but the same shortcut is working in Python files (importing missing packages).
Any thoughts on how to fix the issue.
Below are couple of snapshots for your reference.
The Java Organize Import command is overwritten by another Ctrl+Shift+O command: in Window > Preferences: General > Keys the Java Organize Import command (where When is In Windows) is bound to Ctrl+Shift+O, but in the main and right-click menu Source > Organize Imports the command is displayed without the shortcut.
There are two solutions for this problem:
Change or remove the shortcut of the command that overwrites the Java Organize Import command:
Find the command: In the Java editor press Ctrl+Shift+L and see which command is bound to Ctrl+Shift+O. Probably, it is the Beans Quick Outline command.
In Window > Preferences: General > Keys change or remove the binding for the found command.
Restricts the scope of the shortcut of Java Organize Import to the Java editor:
In Window > Preferences: General > Keys select the Java Organize Import command and change When from In Windows to Editing Java Source. This solution restricts Ctrl+Shift+O to the Java editor and disables the shortcut in the Package/Project Explorer.
See also: Spring IDE issue #160: organize imports is not working
To fix this issue:
Go to Preferences -> General -> Keys
Click on Filters... and de-select Filter uncategorized commands then Ok.
Then look for the command Go To Symbol in File and select it.
Then click on Unbind and then Apply and Close
Ctrl+Shift+O. should now work.
EDIT:
Also unbind any other conflicting commands and leave only one command for Ctrl+Shift+O and set the When to Editing Java Source.
Please keep in mind that if you are using an AMD GPU, your Radeon Driver could block Ctrl+Shift+O which is used to toggle an ingame-overlay. It can be changed to other keys as follows: Games → global settings → performance monitoring
Window -> Preferences -> General -> Keys
Click on Binding to sort by Binding then scroll and find Ctrl+Shift+O
If several Organized imports are present edit one bind and choose WHEN: EDITING JAVA SOURCE.
Remove( UNBIND COMMAND) for other existing bindings.
Restart Eclipse
Above shortcut resulted in GPU details being popped up on my screen. SO it was bound to some other app which was overriding it. What worked for me is
-> check.
You need to go to Gaming > Global Settings > Performance Monitoring > Toggle Performance Logging Hotkey
You will see this is bound to Ctrl + Shift + O (so the shortcut is used - just buried).
To remove the shortcut (not an obvious process at all!) you need to click the Toggle Performance Logging Hotkey button, it will then ask to enter your hotkey, you then press delete - that is Del (not backspace, not esc or anything else - the Del key).
i did all but not worked so i checked the AMD forum (https://community.amd.com/thread/227221) and found out my solution which is;
"Now I find that all I need to do is to go to Radeon Settings -> Preferences and uncheck the Show Overlay box."

How to fix Eclipse autocomplete not working

The autocomplete of eclipse is not working now and I searched for hours but I couldn't find an answer to solve it. I haven't used it for long time then the first thing after opening it was to install SWT and windows builder even though I had swing installed. What I mean is, it is may possibly be because of some conflict caused by swt and swing(I read something about a conflict but I don't if this is possible).
Strange thing is it doesn't show anything when I press ctrl+space but when I go Edit-> Content Assist -> Default(it says Ctrl+Space nearby it), it shows things needed to be shown/works as desired.
public class Dsada {
String sssss;
public Dsada(){
sss //pressing ctrl+space is not working,Edit->ContentAssist->Default works fine
}
}
The solution is not to tick/untick some stuff under Windows->Preferences->...->Content Assist-> Advanced. I checked if "ctrl+space" is hijacked by some other thing which is not and checked keyboard language which is English(Those are suggested in mkyong).
I read something about a bug but I couldn't understand. I tried to delete eclipse and re-install again but I guess some settings just stayed in the machine so that it didn't work.
This is recurring for me. I'm using Eclipse 2019-03 in Windows 10.
The steps below work for my case, and does not require a restart.
Window->Preferences->Java->Editor->Content Assist->Advanced
The following options are de-selected, and when I set them the autocomplete worked as before. No restart needed.
1. Java Non-Type Proposals
2. Java Proposals
3. Java Type Proposals
4. Java Proposals (Task-focused)
I don't know what's triggering this but it only happens after I've created a new project. Usually doesn't. It simply doesn't happen often enough for me to notice a pattern to follow up on more.
Clearly this problem occurs with a variety of causes, so review the other answers to see if they match your case.
The hot key combination ctrl+space might be conflict with other settings in system if you are using windows.
Try modify this combination like alt+/, i always use this one since the first time i knew eclipse. It works well.
Hope it works for you.
Window->Preferences->Java->Editor->Content Assist->Advanced
The following options have to be selected, then the autocomplete worked . No restart is required.
Java Proposals (must be selected, not sure the follows)
Java Non-Type Proposals
Java Type Proposals
Java Proposals (Task-focused)
I was facing the same issue. If you use OS X Eclipse Ctrl+Space shortcut can be interfering with OS X system's "Selecting previous input source" using Ctrl+Space shortcut as default.
It is necessary to
edit System Preferencies/Keyboard/Shortcuts/Input Source and uncheck the "Selecting previous input source" or change the shortcut on something else. Eclipse should work after that even without restart.
I faced hot key problem with use Ctrl+Space. I tried to fix the issue first by Windows->Preferences->...->Content Assist-> Advanced and selected
Select the proposal kinds contained in the 'default' content assist list:
Other Java Proposals,
List item
SWT Template Proposals
Template Proposals
Type Proposals
but didn't help.
Therefore, I tried another solution. There would be multiple languages on your computer which could be eating up your Ctrl command. To solve this Go to Control Panel -> Region and Language -> Keyboards and Languages (tab) and then Change Keyboards.
You’ll see a list of languages installed – remove any that you don’t want (click the language and then click the Remove button) until you only have the ones you want left. That fixed it for me, but you can also check the Advanced Key Settings tab to make sure that none of the keyboard short-cuts that are set include Ctrl-Space.
Once you’ve done that, Ctrl-Space should work nicely!!!!
I had the same Problem on Ubuntu 14.04. The problem for me was that ibus used Ctrl+Space as a shortcut. I solved it by starting the program ibus-setup and chaning the shortcut to something else than Ctrl+Space.
Go to Windows >> Preferences » Java » Editor » Content Assist. Then Check the Auto activation triggers for java, Add this in the text box .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Recently, I also faced this issue. When I install neon version eclipse.
By (1) deleting respective class, (2) restoring defaults appearance and (3) restarting eclipse, solved the problem for me.
Hope it will help someone.
Go to Preferences » Java » Editor » Content Assist » Advanced. Make sure Other Java Proposals is ticked/checked.
I checked windows has no conflict of ctrl+space (of eclipse autosuggestion) with windows.
This is mere configuration issue of eclipse. reinstallation would fix it.
Thanks.
I select all the parameters in Preferences -> Java -> Editor -> Content Assist -> Advanced.
It help me and resolve the my problem.
Cltr+space work using this step.
Saving my work and restarting Eclipse solved this for me. I hadn't shut down Eclipse in a while, maybe weeks.
I had the same problem (MacOS Monterey, Eclipse 06-2022). Turned out it works with pressed fn button.
For Mac user, you can try : Preferences -> Java > Editor > Content Assist and then :
tick the field "Enable auto activation"
in the field Auto activation trigger for Java, you can input the text alphabet ".abcdefghijklmnopqrstuvwxyz"

Keeping Code Collapsed - Eclipse IDE

Just curious if there's a setting somewhere in Eclipse to keep blocks of code collapsed when the class is opened? It's just I'll collapse methods then when the class is re-opened, everything is expanded.
Thanks
In Windows > preferences:
Java > editor > folding: check all, click apply & then OK.
Maybe this helps: Ctrl + Shift+ NUM_KEYPAD_DIVIDE collapse all methods in a java class.
Source
Yes . From the eclipse official documentation :
You can specify which regions are folded by default when an editor is
opened. Have a look at the Opens the folding preference page Java >Editor > Folding
preference page to customize this.
Just click all the checkboxs .Then whenever a .java file is open in the java editor , everything will be collapsed.
Not sure if this options is the new feature for eclipse indigo version (3.7) , so you may have to update your eclipse to indigo if you use older version but cannot find this option.
I'm not aware of a solution, but let me tell you how I work - maybe this is a solution for you as well:
Enable "Only show the selected Java element". The editor will only show the element (method) you selected (see screenshot).
While editing a file use either the Outline view or CTRL + O to navigate through the class file.
Btw: I disabled all folding options as the above approach just works best for me. Sadly, I'm not aware of a shortcut to enable/disable the "Only show the selected Java element".
Yes, you can set the options what to fold on file open.
You can find it at Settings->Editor->Folding
It features a resonable selection of folding options.

Any way to get IntelliJ-like autocompletion in Eclipse?

I'm stuck with Eclipse in one project and I would like to have autocompletion similar to that of IntelliJ - two major problems are:
Start typing and Eclipse would automatically suggest all possibilities
When there is item selected in dropdown list you can accept it not only with enter key but with dots, spacebars...
Go to Window → Preferences → Java → Editor → Content Assist.
In the column "Auto activation triggers for Java", enter this:
.qwertyuioplkjhgfdsazxcvbnm_QWERTYUIOPLKJHGFDSAZXCVBNM
Add any other keys you want. You're done. That answers your first query.
As far as second one goes, I think it already exists.
Take a look at Eclipse Code Recommenders [1] or Codetrails Connect [2]. They make Eclipse' code completion intelligent.
[1] http://eclipse.org/recommenders/
[2] http://marketplace.eclipse.org/content/codetrails-connect-community-edition/
I have to say NO. I moved from Eclipse to IntelliJ because of the intellisense and inability to make Eclipse behave like IntelliJ (or if you come from the .NET environment: inability to make Eclipse intellisense behave like ReSharper in .NET).
Do you HAVE TO work in Eclipse? I do 98% of work in IntelliJ, then convert the project into Eclipse project (IntelliJ can still access it) and finish it in Eclipse. Maybe you could try this solution.
Since Eclipse Juno, Code Recommenders Intelligent Java Proposals replaced the old JDT's Java Proposals.
It afford "Intelligent Code Completion" function, like IntelliJ did in a way.
You can get something useful through the link below:
http://code-recommenders.blogspot.jp/2012/07/code-recommenders-10-code-completion-on.html
There is something like that in Eclipse I think, certainly in the Eclipse Helios. When typing you press CTRL+SPACE, or when you typed variable name '.' will start auto-complete options.
Also here someone suggests to change auto complete delay settings to 0.
BTW you can also accept your selection with space bar, for sure.
EDIT:
Why not consider using NetBeans, my personal favourite. There you have an option to show auto-completion on start typing any Java Identifier Part. This would then look exactly as you want it. (in NetBeans Tools->Options->Editor->Code Completion, there in Language box select Java and finally check Auto Popup on Typing Any Java Identifier Part).

Eclipse shortcut to run a class

I have an Eclipse project where I often launch the same java class. I have added my run configuration to the favorites menu, but to launch it I still need to click on the run-drop-down menu and click the icon - is there any way to associate a shortcut to this? When I searched for it I got lost in all the plugins & other things which seemed to be not so simple.
edit: Let me clarify, I want something I can type the moment I start eclipse, regardless of what page I'm viewing, so no "run last" or "run current"; I want F12 to link to "launch foo.bar.MainClass".
Just use Ctrl + F11. (This is the standard keyboard shortcut to run the class you are working on)
I wish this is what you are looking for... buddy.
Open the workspace preferences by the menu: Window > Preferences
Select from the tree: Run/Debug > Launching
Now the Launching preferences are seen.
At the bottom there is Launch Operation
Use the option Always launch the previously launched application
You can configure your launch behaviour so Ctrl-F11 will launch the last launched application again, regardless of your current editor selection.
Look at "Run/Debug" - "Launching" within the eclipse preferences.
alt+shift+x+J Rocks
You can go Window -> Preferences -> General -> Key and bind anything you want!I hope it helps!
You should put in a feature request in the eclipse bug tracker (or vote up an existing equivalent feature request) or code it yourself.
It is Ctrl+F11
Ctrl+Shift+X or Ctrl+Shift+J didn't worked for me!
If you've added these classes to your favorite run configurations (available from the run/debug toolbar buttons as "Organize Favorites..."), then the shortcut key combo is Alt+R,T,1 to run your first favorite, Alt+R,T,2 to run your second, etc. Alt+R,H,# works for debug configs.
on Windows machine
ctrl+Fn F11 --- running
ctrl+Fn+Shift F11 --- debugging
If you are someone like me who wants to create a shortcut to run a class/program in java directly, you can create your own preferable shortcut in ECLIPSE!
Follow these steps:
Window > Preferences > General > Keys
Select run from command column
Enter your own shortcut in Binding section
Apply and close!!
WARNING: Make sure you don't create a shortcut which is already assigned for a different task!
I cannot this the answer here but : CTRL+SHIFT+T do apparently exactly what you want! :) Maybe it's because you code it by yourself by time...
Watch here: http://eclipse.dzone.com/news/effective-eclipse-shortcut-key for more.
I faced this problem in eclipse too. I have customized the configuration for me.
Windows -> preferances -> keys
Search for your configuration eg "Run Java Application" or just look for its icon.
Select it
and below in the binding field press keyboard keys which you want to add a shortcut for this configuration eg. ctrl + shift + T
and Apply
You are good to go use the same shortcut keys to whenever you need it.
Just create an "External tool configuration" instead of a standard configuration for the class you want to run, and assign a shortcut key to "Run last launched external Tool".
Of course, there shall be no other external tool configuration.
Even if other java programs have been launched, or the current class contains a main() method, hitting the shortcut key will always run the same configured class.

Categories

Resources