When I load a sample application in netbeans (anagrams that comes with it) and I hit run, the program just runs .. how can it determines the entry point for the program (class which has main method) ...
All classes that can be run have a small green triangle on their icon in the "projects" view.
If a default class is set to run with the project, you can see it by right-clicking the project and selecting "properties". Then in the project properties, go to "Run" and you should be able to see the main class.
Related
I am trying to debug a java file in netbeans 8.2 and I am getting this error. I have seen posts on netbeans 8.0 that show where to set the main class but it has moved in 8.2. Can someone point me to what I need to change to allow debugging in netbeans 8.2
Under the categories menu there should be a run option to make this setting but I do not see a run option.
There is run listed under the categories menu, however, there is no setting for main class.
First off...does the file you're trying to run contain a main() method? If not then there must be a class that does. You can select which Class will be considered the Startup Class by doing this:
With you mouse pointer, select the Project Name within the Projects
pane typically located on the left side of the NetBeans IDE;
Right-Click on the Project Name and from the popup menu select
Properties;
From the displayed Project Properties windows select Run from
the Categories pane;
On the right side of the Project Properties window you will notice a
label stating: Main Class. The Class which is considered the
Startup Class is displayed within the Text Field. Select the
Browse button located at the far right and then select your desired startup class from the Main Classes popup dialog window;
After selecting your desired startup Main Class select the Select
Main Class button to close the popup dialog then select the OK
button located at the bottom of the Project Properties window;
Done. Run your application.
I have an experimental project that used to write some ADT like stuff in which there are packages like linkedList, streams, sorting, stacks, sockets etc.
Every class has own main method, Like in eclipse we can run the class from the option menu but how this can be done in intelliJ ?
See, you can also run your public static void main directly like in eclipse. IntelliJ automatically have this run config. But to have this all you need to do is set your source folder.
So, File> Project Structure > Modules , the select src and mark as sources.
For more details : https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
After you have done this, you will see small green triangles on left near your public static void main from where you can run and debug.
You see that J small icon on top of Java icons files in project window on left. This is indication that you have not configured your sources folder .
See : What does this symbol mean in IntelliJ? (red circle on bottom-left corner of file name, with 'J' in it)
You can create your run configuration for each main class from Run -> Edit configuration.
Here's the guide link
Editing answer because of comments below:
See this link: imgur.com/a/1H5Xhj8 Here I ran class A and B and I can see in run config menu. Now I created class JJ. I still can see green triangles on this class but not in dropdown. N.B: I'm not using ultimate version but community edition. Hope it's not an issue
Below is the code in eclipse,
public class MBILogin extends
com.sterlingcommerce.woodstock.ui.servlet.MBILogin
These are two different MBILogin from two different packages.
I am unable to find the second MBILogin class in the jar file. I have used a decompiler for illustration.
When I hover over it with my cursor, it shows an error error to the effect of "create MBILogin class in such and such a package" or "fix the project," but I'm able to build the project successfully and the application works as expected.
I am unable to discover where the MBILogin class (in that com.sterlingcommerce.woodstock.ui.servlet package) is coming from.
Please give any suggestions to find that class file.
Eclipse provides an easy way to track the project/library where a class is located on:
On a source code window, simply hover the name of the searched class while pressing CTRL. Then click on it, and let Eclipse open it on a new window (no matter if it shows just bytecode and no source code).
Then, you must click on the Link with editor button of the project explorer view: This will show the library/project where the class in active editor window is located.
I wrote two java projects which are purely independent.
When I run the first project "aa", automatically a "Run Configurations" window appeared, and I chose "cc" (cc.java) under Java Application tab.
The app run.
but when I made another java project "dd" and wrote code in its class "ff", The run button showed the output of cc.java in console.
I had to go to "Run Configurations", and select "ff" (ff.java) under Java Application tab.
Why I have to to do this everytime?
What if I have multiple classes under one project?
Is there anyway to run a project by simply clicking run button?
Regards,
BAQAR RAZA MANGRANI
Struggling programmer.
As far as I know, if you have several classes including a main method in eclipse, as soon as you run them once, they appear as shortcuts when expanding the run button(or debug). Just click on the small arrow next to the start button and select the file you want to run.
Ok, I have a(n) RCP application (that I didn't write), and an application I've developed using just SWT. What I want to do is basically import and launch the main method of the SWT application with arguments, such that it runs in another window, like it's another process. The argument I want to pass is a complex data structure that I don't want to serialize.
I originally thought I could just design my SWT app to be a library and import it, have it spawn its shell, etc. But I neglected to think about how the SWT app's main loop has to run on the main thread, which seems problematic.
So I started looking into integrating it with the eclipse plugin architecture. Problem: I don't know anything about the eclipse plugin architecture or RCP, and when I try to learn, I run into an inscrutable wall of things that are totally unlike what I want to do (ie building new buttons onto the eclipse workbench). How do I get started developing a plugin that just launches another window?
You will need some kind of button to launch your application so just must hook into the Eclipse menu system.
Try:
1) In Eclipse, File -> New Project-> Plug-in project
2) Make sure you check "This plug-in will make contributions to the ui"
3) Uncheck "generate activator" since you won't be needing it
4) Select "Hello World command" from the code template
Now you will have a sample handler and a method called execute where you could call your SWT-application with the display you're using in the RCP-application. If you really must call void main(String[] args) you could get the display by calling Display.getDefault(), which will either create a new display or use the one from the RCP-application.
You will also have to modify the plugin.xml file so it points to the correct menu in your RCP-application. If you want your launch command to be in the file menu etc.
Finally, right-click on your project and select Export -> Plug-in Development and create a jar-file where you launcher will be in. Drop that jar into the plugins folder of the RCP-application and you should be able to launch the SWT-application from the command you've just created.
There will probably be a couple of bumps on the way, but that's roughly what you will have to do.