get all the classes with main method in Eclipse Java project - eclipse

I'm working on an Eclipse plugin to help people manage their project.
Is there a way to list all the classes with the main method under a project by Java code?

I think the best practise is to use only keyboard.
Create new java class with Ctrl+n
on dialog box, enter its (class) name
use (left)Alt+v to easily tick checkbox for - public static void main(String[] args)
then press [enter] Finish and voila class is ready

Related

Any useful netbeans shortcuts?

Anyone knows any useful Netbeans shortcuts? in eclipse for example, i used to type sysout and press CTRL+Space, anyone knows any equivalent shortcuts? Thanks in advance ;D
What you are looking for is called Code Templates. You can find them under Tools / Options / Editor / Code Templates. There you find a (quite extensive) list of code templates that already comes out of the box but you can also define your own.
If you type in NetBeans for example psvm and press than the tab-key NetBeans will generate
public static void main(String[] args) {
}
for you.

Eclipse running previous program

It is a new problem. I copy paste a program and try to run it in eclipse. But the eclipse keeps running an older program. I have no idea what is going on. ( I saved the program as someone on the internet suggested) In the run button, there are only old programs. So I goes into the run configuration option and double clicked the java application option and somehow the one I am working on right now appeared. And I am able to compile and run the current one. So technically I solved the problem, but I would like an explanation, what was going on?
What is going on here is how Eclipse decides what to Run when you press the Run button. My suspicion is you have settings which are causing it to launch the last launched item, rather than something new that does not have a launch configuration. If you hover over the Run icon, it will show the name of the launch configuration that Eclipse will launch.
For a new program, you want to do a Run As -> Java Application (From Run menu).
To configure the default launching behaviour, see Preferences -> Run/Debug -> Launching, and then set the options you want in the Launch Operation group.
It just copies path of the server from old project.
It has the TWO solutions :
1) you can simply click on your Tomcat->Modules (Web Modules)-> Edit
And simply change the path with you project name or just put "/".
OR
2) You can right click on your project -> Properties-> Web Prjoect Settings
edit Context root, just simply put "/"
Thank you
I run into the same problem (I am new in java). I solved the problem by * I ensure did not use the defaul package . Step 1. Create java application. Step 2. Create package (stay away from default package). Step3. Create a class that will have my getters and setters (example:
package revature;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student();
s.setName("vijaiy");;
//getting value of the member
System.out.println(s.getName());
}
}
Step 4. Create the main class to run the program
Example:
package revature;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student();
s.setName("vijaiy");;
//getting value of the member
System.out.println(s.getName());
}
}
My problem was that I did not set up my brain to think 'java', I was thinking on 'javascript'.
Exit out of eclipse, then open Eclipse in a new Workspace and create a new Project. This is a quick solution if you are willing to have multiple workspaces.

Eclipse Luna version 4.4.2 not showing suggestions for java 8

I recently installed Java 8 64 bit version on my machine and installed Eclipse Luna version 4.4.2 64 bit.However when I programme a java application,the IDE not showing auto suggestions to use Java 8 features like use lambda expressions instead of anonymous inner class.The code I have used is given below.As my reputation is low I am not able to post images.
public static void main(String[] args) {
Thread t=new Thread(new Runnable() {
#Override
public void run() {
System.out.println("Run method called");
}
});
t.start();
}
Works fine for me in Eclipse Luna 4.4.2. I press Ctrl+1 when staying on new Runnable:
Seems that there's no way to mark it as warning (yellow lightbulb). However you can switch on a save action for lambda. Go to Preferences -> Java -> Editor -> Save Actions, check "Additional actions", press "Configure", go to "Code style" tab and check the "Convert functional interface instances":
This way all the anonymous classes which can be converted to lambdas will be converted automatically upon you press Ctrl+S. You can also make this conversion for the whole project at once: select the project in Package explorer, right-click, Source, Clean up, Use custom profile, configure and check the same checkbox.

Accidentally created Java application instead of JavaFX

Using Netbeans 8.0.1, I have created a simple Java (ant) project instead of a JavaFX project. Is it possible to convert this project to a JavaFX project? In that case, how do I do that?
Thank you very much.
If you're using Java 8, the JavaFX classes are on your classpath.
You can just create a class that extends javafx.application.Application and implement the start(Stage stage)
and
main (String[] args)
methods.
Next, in Project Properties go to the "run" tab and select your new class as "Main Class"

Command shortcut in intellij-idea

In eclipse by typing "main" and pressing Ctrl+Space you can generate main method, and there are lots of other shortcuts like this.
Is there anything like this in intellij-idea? and how can I assign them?
Depending upon your key configuration, you can type ⌘J for the Templates.
Also see: What are the most useful Intellij IDEA keyboard shortcuts?
Yes, just type sout and press tab button the main method with complete signature will be generated for you.
By default configuration shortcut for public static void main(String args[]) is:
psvm + TAB
psvm stands for Public Static Void Main