E
E
EVOSandru62015-04-09 12:00:20
Java
EVOSandru6, 2015-04-09 12:00:20

How to run non-main Java classes in netBeans?

Good afternoon,
I created a project in netBeans , when I created the project, wizzard offered to create a main class, I named it Salut . Then I manually created several classes attached to the same package, but for some reason when I switch to these class files in the editor, Salut still starts . How to be right? I'm reading Eckel's book, nothing has been said about packages so far. How to run other classes?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
Timur, 2015-04-09
@EVOSandru6

In order to run a class, it must contain the main(String [] args) method.
I don't know about NetBeans, but in Eclipse - the context menu on the class -> Run as Java application.

E
EVOSandru6, 2015-04-09
@EVOSandru6

Shift + F6

B
bruxo, 2018-01-22
@bruxo

A similar situation arose, Shift + F6 starts the project, but when launched through the "green Play" it swears that the main class is not configured, the following helped me: Project properties -> Execution-> "Main class" field, looks like Package name. class name, choose from the list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question