Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Is possible to have multiple FX programs in the same module ?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You know, when you started, you created a file to store your java programs (that run on the console)  without running into issues like:

Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\name-\Desktop\HelloFX\target\classes
Caused by: java.lang.module.InvalidModuleDescriptorException: JavaProgramtest.class found in top-level directory (unnamed package not allowed in module)

Before this error popped, i have already created a project called helloFX and setup the configurations / VM options and in that same project, in the java file, i created another javaFX program but it gave the error you see above.

I looked into the configurations as i was told that i would need to call the show() method. Though, object.show(); didn't work and tried going to the configurations to check the path and there was no "VM options" dialog.

Is it even possible ? or do i have to create a new project everytime i need to create a new program ?

I'm new to javaFX and so demotivated with all this ~.~ i need help.
 
Greenhorn
Posts: 22
IntelliJ IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>  (unnamed package not allowed in module)

Doesn't look JavaFX specific to me.

Have you tried putting your source files inside a package (folder)? Normally we use naming standards for packages like net.yourapplicationname for example, Which would mean your source folder contains a "net" folder and inside that is another folder with a name specific to your application, and that folder contains your java files.

I don't know what your project file structure looks like but for Ex:
HelloFX/src/java/net/app/Main.java
 
Saloon Keeper
Posts: 13505
305
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message literally tells you what's wrong: unnamed package not allowed in module.

Follow Lou's advice and put all your classes in a package always.
 
Lou Hamers
Greenhorn
Posts: 22
IntelliJ IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah it's always recommended to do this with all versions of Java, but with Java 9 "jigsaw" (module system) it's crucial because the module system makes use of package structure by design. Hopefully the module system doesn't get too much in the way of new developers but I suspect it does (like here)...

Also you may find it far easier if you install (and be sure your IDE is using) a JDK that has JavaFX built in, such as one of the Azul/Zulu "FX" JDKs.

https://www.azul.com/downloads/?package=jdk-fx

Otherwise with a regular JDK you'd need to follow the more involved instructions at: https://openjfx.io
 
Lou Hamers
Greenhorn
Posts: 22
IntelliJ IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:The error message literally tells you what's wrong: unnamed package not allowed in module.

Follow Lou's advice and put all your classes in a package always.



That's true, but I guess if you're new and you don't know what a package or a module are, it would still be confusing. Kind of a shame the module system just added yet another layer of learning curve for new people.

IMO probably a good idea for new developers to do a read up or some class/tutorials to go over basic terms like that before writing a line of code.

Oh, and as for the answer to the question in the thread title - yes it is possible to have multiple classes implement main().
 
M Lane
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So i downloaded zulu but i dont see the net file you speak of.

The only thing here that isn't being shown in tutorials or the classes i take is that they don't show you how to do this specific part (on a udemy course, the prof just creates another project and in a book he skips the entire configuration process)

I usually place it in the java folder but i suppose that's wrong, could you guys tell me where exactly can i put it.

i'd like to start reading the book again (intro to java programming 10th edition by Jiang)
Screenshot-(37).jpg
[Thumbnail for Screenshot-(37).jpg]
 
M Lane
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay so, i got so fed up with it that i went ahead and deleted every project made and started another one (I have to add that i didn't touch "Edit configurations" this time, just created the FX project and started working on it.

The problem disappeared

maybe zulu did something, also i did place the javaFX file in the com.example.demo package which was in the java folder (is this what you meant ?) i realized its a package when i wrote the code :

dumb me.
 
Lou Hamers
Greenhorn
Posts: 22
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep all you needed was to place it inside a package (directory).

You're right that a lot of tutorials and docs don't show you project file structures. I guess it takes more effort to do that... so sometimes it also helps to find a simple example project on GitHub and see how it's structured.
 
Stephan van Hulst
Saloon Keeper
Posts: 13505
305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, does your project reference a local JavaFX implementation, or is JavaFX listed among its Maven dependencies. I STRONGLY recommend using the latter option.
 
M Lane
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:By the way, does your project reference a local JavaFX implementation, or is JavaFX listed among its Maven dependencies. I STRONGLY recommend using the latter option.



I don't even know what either of these are.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic