Running a project in NetBeans? - java

In Eclipse, running a project is as simple as clicking the run button.
In NetBeans, I'm totally confused. How do I run the program? If I print something, where does it go (e.g. the console in Eclipse)?
Thanks!
EDIT: Solved it. For some reason it was running a different application than the one I had selected. Anyone know why?

It's the same in NetBeans, just klick the "Run" button (you need to have a main class defined though)
The output goes into the "Output" window which is displayed at the bottom of the editor by default.
If you don't see the output window, you can display it using the menu "Window -> Output -> Output"

In the menu, see Run > Run to run a project.
On the bottom right, find the output windows, that's where the print will appear.

Related

Sometimes Netbeans disables the run button

Sometimes Netbeans disables the run button.Help me to overcome this problem.I can't keep restarting netbeans again and again.When I get this problem my clean button also get disabled.
Do Run -> Set Main Project and select your project.
To explain: netbeans is very context sensitive and you may be moving out of the context of your runnable project. In general, clicking any source window thats part of the project will enable the project's Run button but if you, for example, open some random text or csv file to take a look, the Run button will disappear because the text or csv file you're looking is not part of the runnable project -- you've moved out of the project's context.
Setting a project as Main will cause it to always be the 'in context' project with respect to the Run, Debug, Profile buttons.
As the comment mentioned, your app also might still be running and you should see a Stop button to press.

Eclipse Reads from a different class(file)

This problem continues to persist and I am hoping that someone who understands Eclipse can help.
Previously, I worked on a project that involved reading files. However, I am complete with that project and now my current project keeps reading the previous file.
I just want to run programs seperate from the personalityy.java file
I have already tried run -> configuration
Screenshot
It reads from personalityy.java
You're pretty unclear about what exactly you're trying to do, but in short, to run a java application, right-click on the source file in the explorer and select "Run As" and "Java Application".
It looks like you are new to Eclipse. Don't worry the problem is pretty simple. The Green run button on the menu bar will run the last run program by default. You probably have the new file open and you are using the run button in the menu to run. What you have to do is.
Open the file you want to run.
Right click inside the new file in text editor
Click Run as
Click Java Application.
In the future you can click the black down arrow beside the run button to select which program you want to run.

Trouble getting my Android Studio application to run

I got this application to run previously, but since I clicked 'End Task' on Android Studio in the Task Manager in the middle of importing something, it's not working anymore.
deleted screenshot
The problem is in the screenshot above. The run button is greyed out. I can go to Run in top menu --> click Run, it throws up a box prompting me to edit configurations. I click on that, then click Run in the box it throws up, but nothing happens.
My java classes have a red icon next to them, whereas in other applications, they have a blue icon with a letter C. That looks to be the problem.
Anyone know what the problem could be? If you need more information, I am happy to give that.
Fixed: This was sorted out going to File --> New --> Import Project, clicking Next on each window, then 'Finish'. Then Run in the top bar, click 'Run', application runs successfully.

Running a program in eclipse

Each time I try to run a new program, an old program 'client.java' is run by eclipse. How do I change this setting? How do we tell eclipse which program to run? I tried using the arrow beside run button but it dosen't list out my new program.
You can change the default behavior by going to Window > Preferences > Run/Debug > Launching and in the 'Launch Operation' section, select the radio button for Launch the selected resource or active editor and then select Launch the associated project underneath.
Right Click To the class -> Run As-> JAVA Application
Firs of all make sure that your program has a main class.
Then click in the black button next to the run button -> Run As-> JAVA Application.
If this doesn work make sure you have all this properly set up.
Run Configurations

how to stop losing focus when something is printed out to eclipse Console View?

I'm suffering from an annoying feature in Eclipse 4+.
I start a program which will generate some output to the Console view periodically,Then i continue editing the source code in Java Editor,when the output comes out,I lost focus in the Java Editor.This would'nt happend in Eclipse 3.7.
how to avoid this ?
Top right of the console view there there are two icons indicate "Show Console when Standard Out changes" and "Show Console when Standard Error changes",I see they are checked,when i uncheck them, the problem solved.
One of the icons at the top right of the console should do the trick.

Categories

Resources