i am new in java and i am a student, I am using net beans 8.0 for java developing i created a project and run it using Shift+F6, it is working fine, but when i go for build project from the project categories then in the "Browse Java FX Application Classes" window nothing display in "available classes" so therefore i can't build my project. Moreover the dist folder also not exist in my project.
Please let me know how to resolve this problem where i am wrong or which option i miss.
Thanks in advance.
It needs to find the class that extends Application. You can right click the project in the project window the choose properties then run. You will see a box for Application class. You should be able to select the class there.
If there's nothing in the 'select classes' box then maybe you forgot to declare the class like
public class JavaFXApp extends Application {
//etc..
Related
I have worked with NetBeans in the past and I wanted to work with it again, it was a long process of installing but I finally got it, and now that I am here it will not let me run my projects.
For one: It does not create a project with ant(at all)
For two: whenever I create a class it does not automatically close the name the class screen
For Three: When I right-click my class the run-file option is greyed out
For four: When I click run project the screen is stuck on "Initializing view, please wait..."
I really need to get this to work and I just can't seem to figure out what I'm doing wrong or if I am even doing something wrong.
Regarding the 4th problem:
You need to set the main class in your project.
Right Click on the project folder, then click properties.
Get to the tab run.
Now type in the direction of your Main class you want to run:
package + name of the class
example:
package name: com.mycompany.myproject
class name: MyClass.java
-> directory of Main Class: com.mycompany.myproject.MyClass
click ok and try again
Worked for me
Some suggestions to try:
Run a clean and build
Right click the project --> properties --> ensure the correct main class is set
Upgrade and/or restart NetBeans
Good luck!
Had the same issue, couldn't get it to work for the life of me, installed the latest version and everything went smoothly. I suggest not wasting time troubleshooting as I did, but instead updating to the latest version first.
I just downloaded eclipse for Java Yesterday but when I was trying to get make my first program, I kept on getting this error:
must declare a named package eclipse because this compilation unit is associated to the named module x.
How do I fix this?
Just delete module-info.java at your Project Explorer tab.
The "delete module-info.java at your Project Explorer tab" answer is the easiest and most straightforward answer, but
for those who would want a little more understanding or control of what's happening, the following alternate methods may be desirable;
make an ever so slightly more realistic application; com.YourCompany.etc
or just com.HelloWorld (Project name: com.HelloWorld and class name: HelloWorld)
or
when creating the java project; when in the Create Java Project dialog, don't choose Finish but Next, and deselect Create module-info.java file
Reason of the error: Package name left blank while creating a class. This make use of default package. Thus causes this error.
Quick fix:
Create a package eg. helloWorld inside the src folder.
Move helloWorld.java file in that package. Just drag and drop on
the package. Error should disappear.
Explanation:
My Eclipse version: 2020-09 (4.17.0)
My Java version: Java 15, 2020-09-15
Latest version of Eclipse required java11 or above. The module feature is introduced in java9 and onward. It was proposed in 2005 for Java7 but later suspended. Java is object oriented based. And module is the moduler approach which can be seen in language like C. It was harder to implement it, due to which it took long time for the release. Source: Understanding Java 9 Modules
When you create a new project in Eclipse then by default module feature is selected. And in Eclipse-2020-09-R, a pop-up appears which ask for creation of module-info.java file. If you select don't create then module-info.java will not create and your project will free from this issue.
Best practice is while crating project, after giving project name. Click on next button instead of finish. On next page at the bottom it ask for creation of module-info.java file. Select or deselect as per need.
If selected: (by default) click on finish button and give name for module. Now while creating a class don't forget to give package name. Whenever you create a class just give package name. Any name, just don't left it blank.
If deselect: No issue
My friend and I both have IntelliJ and just want to run plain old java. Every time I make a new java class, I can automatically run it. The configurations just work.
When my friend wants to run it, he has to go to edit configurations and type in the class name. We went through the exact same setup. How do we make it automatically the main function in the class?
Friend's
MINE Macbook Pro
When you're in a java file that contains a public static final void main(String[] arg) method you can press Ctrl+Shift+F10 to make and run a temporary run configuration for the current class. This can save a bit of time when setting up the configurations.
Alternatively you can try to share the .idea directory with him, as it contains all of the project's settings. I'm not sure what other options will be shared though.
it's easy, Your friend must do this and this setting is changed in the "Default Project Structure..." dialog. Navigate to "File" -> "Other Settings" -> "Default Project Structure...".
Next, modify the "Project language level" setting to your desired language level.
IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."
Creating files in the src(source folder) where the jvm expects to find the java classes instead of creating them in the project root folder helped solve the problem for me.
I'm doing my 1st steps in Android/GoogleApp, and I'm trying to explore the Jumpnote example:
http://code.google.com/p/jumpnote/
I was able to import the Android and Appengine projects to eclipse, but encountered the following issue when trying to run the Jumpnote-web part (android runs well).
When running the web part there is an error Main type is not specified which AFAIK implied that this project is missing a main function.
Is that indeed the case for jumpnote example and I need to manually add it, or am I missing something else?
Go to run Configuration
select JumpNoteWeb run configuration
You see in the main tab your project name and below it says main class
In the main class, put "com.google.gwt.dev.DevMode"
it should now run
*When I had this problem I also need to make sure that I put the src.shared folder into my project and had to change my build order so the app engine sdk, gwt sdk, and jre would build first
I want to access a class which is present in another project . For that i use java reflections,but first i need to get the class object which is in another project.I want to get it programatically.I can do that like right click on my project then go to build configure path and then to project tab and add project.I want to do it programmatically .How can i do that?Help
You need a custom class loader.
tutorial link1
tutorial link 2
I think you can do it by creating a jar of the dependent project and adding it to class path before you run your application.
It seams you are working in eclipse and want do use the classes from projet B in projet A, is it so?
If so you could specify in eclipse that project A depends from project B by adding the project in the 'java build properties'.
Do get the right answer, you ask to be more specific in your question like Steven wrote.