Eclipse shortcut to run a class - java

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.

Related

why is the shortcut, sout, not working for me in IntelliJ IDE

I've been doing mooc.fi to learn java but because my computer didn't let me install netbeans I used a plug in within intelliJ. For some reason it doesn't respond when I use the shortcut sout but instead puts SQLOutput
You can edit the shortcuts in IntelliJ in the settings tab.
Settings/Preferences -> Editor -> Live Templates. Find out the "sout" shortcut and put "System.out.println();" in the expands to section.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008575319-sout-shortcut
I had this problem too. My issue was I was trying to 'sout' outside of the main method, so make sure you're inside the main method first.

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 do I map a key in eclipse to run the project run configuration?

I created a new eclipse project with a new run configuration. This configuration is visible on the drop down menu for run configurations and has a 1 on it. How do I assign a Key to run exacty this configuration?
The problem I have is, that I use eclipse to write scala, and the hotkey "Run as Scala" does only work if my editor has the file with the main class opened (WTF). On all other files I get the error message "Editor does not contain a main type" without any further information. So I created a run configuration, where I specified the Main file, but now I don't know how to start this configuration without touching the mouse.
The hot key to run something is Ctrl-F11.
works best Alt+R then T then 1.
Refer to Shortcut for selecting run configuration in Eclipse IDE which said to use ALT+R, N, and then type a name, which shows Run Configurations for me.
Best option:
Assign (bind) a shortcut via Window > Preferences, General > Keys
The command to select is "Run..."
(I added this answer because for me the accepted one shows Run Menu, then T is for Terminate, nothing to do with Run Configs)

Ctrl + U shortkey of IntelliJ idea equivalent in MyEclipse

I do used IntelliJ IDEA as my development environment at past and I have recently started to use MyEclipse.
In IntelliJ, using the Ctrl+U shortcut on override/implement method go to original method in super class.
Does MyEclipse have similar shortcut and if it does how do I use it?
Assuming MyEclipse has the same menu command as standard Eclipse, the equivalent command is Open Super Implementation on the Navigate menu. It doesn't have a keyboard shortcut assigned by default, but you can add one.
You can do this by pressing Ctrl+ mouse over the method it will show drop down list and in that it has open super implementation. And you can also set your customize key from Help --> key assist menu..

Netbeans IDE - Automatic Suggestion while typing

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

Categories

Resources