Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 17 of 17

Thread: Error reading the module..

  1. #1
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error reading the module..

    early on i was watching videos on udemy and youtube for javafx but they all lead to creating a new project for each program.

    I didn't like the fact that the code was pre-written for me so i went back to a book called "Introduction to java programming 10th edition" by Y. Daniel Liang.

    Chapter 14 talks about the basics of creating the program but not on how to set it up.

    Do i really need to create a new javafx and go through all that trouble setting up everything every time i want to create something ?

    In the previous chapters it was as simple as, right click src > new > java class and thats it!

    I'm completely oblivious to javafx but i understood more from reading a few lines in a book than listening to people talk.

    What am i doing wrong ?[COLOR="Silver"]
    Attached Images Attached Images
    Last edited by Universecloud9; December 28th, 2021 at 08:21 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    Please copy the text and paste it here that you have questions about. The posted images are very hard to read.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    Quote Originally Posted by Norm View Post
    Please copy the text and paste it here that you have questions about. The posted images are very hard to read.
    Error occurred during initialization of boot layer
    java.lang.module.FindException: Error reading module: C:\Users\r-\Desktop\HelloFX\target\classes
    Caused by: java.lang.module.InvalidModuleDescriptorException: Package HelloApplication not found in module

    Process finished with exit code 1
    Attached Images Attached Images

  4. #4
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    Its a serious question you know : probably stupid but please i need an answer.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    What command are you executing that returns that error message?

    If it is from deep inside of an IDE I probably can not help you.

    The people at this forum would be more help:
    https://coderanch.com/f/98/JavaFX
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    package com.example.hellofx;

    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.stage.Stage;

    public class JavaProgramtest extends Application {

    @Override // Override the start method in the Application class since the start class is an abstract class.

    public void start(Stage primaryStage) {

    //Create the scene and place a button in the scene

    Scene scene = new Scene(new Button("OK"), 200, 250);

    primaryStage.setTitle("Khello and velcome to javafx");
    primaryStage.setScene(scene);
    }

    public static void main(String[] args) {
    Application.launch(args);
    }
    }



    that code is placed after making a javafx class inside the hellofx folder. What i mean here is that after i created the first "hello world" for javafx, in that same file i created another java file when excuting the code above, i get the error message. Check the pictures, not the first one but the rest (called error1,2,3).

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

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    in that same file i created another java file
    Each java class should be in its own file. I'm not sure what "in that same file" means.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    As i said, in the previous chapters, before javafx, creating a new java file was as easy as right clicking the java file > new > java class. from there making new code and running it has never been a problem. Why doesn't it work with javafx?

    The new thing with javafx is that i have to open run/debug configurations among other things to get the thing working but can't i, after all that just create a new java class in that file without having to do all that ?

    I suppose it isn't that big of a deal but i just want to know. A bit lazy but man, i like to ask alot of questions to clear things for the future.

    That error i'm getting is basically telling me that the file is in the wrong section (sadly i can't upload a better picture since the max resolution on this site is like 620x280), do you know (from the image "error 2") where can i place the java class for it to work or that isn't possible at all ?
    Last edited by Universecloud9; December 30th, 2021 at 12:01 AM.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    where can i place the java class
    What tools are you using to compile and execute the program?
    Are you executing commands in a command prompt
    or are you using an IDE to do it?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    intelliJ

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    Sorry, I do not know how to use that IDE. Is there a forum for that IDE where you can ask how to configure it for Java Modules?
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    Configuring it isn't the problem, i just don't like doing it over and over every time i want to make something simple .-.

    I legit stopped programming because of it. I'll post it here if i ever find something.

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    doing it over and over every time i want to make something simple .-.
    If you don't type (or paste) in the code, how will any editor know what code to include to do what the program is desired to do.

    I am able to compile and execute your javafx program by configuring the contents of the commandline to use.
    The code is missing a call to the Stage class's show method.
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    Quote Originally Posted by Norm View Post
    by configuring the contents of the commandline to use.
    The code is missing a call to the Stage class's show method.
    Could you please explain the process ? are you talking about stageObject.show() ? i tried that (inside the start method) and still getting the same error.

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    On vacation
    Posts
    24,792
    Thanks
    57
    Thanked 2,687 Times in 2,637 Posts

    Default Re: Error reading the module..

    The code needs the call to the show method to work.

    The process for building the commandline was trial and error. I added modules to the commandline until it worked.
    The commandline I used:
    D:\Java\jdk-17\bin\java.exe -cp .;..\..\. --module-path "D:\Java\javafx-sdk-12.0.2\lib" --add-modules=javafx.controls --add-modules=javafx.fxml JavaProgramtest
    If you don't understand my answer, don't ignore it, ask a question.

  16. #16
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    Quote Originally Posted by Norm View Post
    The code needs the call to the show method to work.

    The process for building the commandline was trial and error. I added modules to the commandline until it worked.
    The commandline I used:
    D:\Java\jdk-17\bin\java.exe -cp .;..\..\. --module-path "D:\Java\javafx-sdk-12.0.2\lib" --add-modules=javafx.controls --add-modules=javafx.fxml JavaProgramtest
    I am so confused O_O isn't a method part of a class?

    Looking at the directory and it seems like you're dealing with the configuration files (those vm options) with adding modules but when i go to "Edit configurations" and select the program i make (other than the one created in the video tutorial which had the vm options), it doesn't contain "VM options".

    Mind you I'm creating a new java class in the same folder as the HelloFX program (which would normally work if it wasn't a JavaFX thing which leads back to my main question as to whether its possible or not).

    In case you're wondering, i also used selected JavaFX as a new class in the java folder to see if its any different but nope.
    Last edited by Universecloud9; January 7th, 2022 at 11:25 PM.

  17. #17
    Junior Member
    Join Date
    Dec 2021
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error reading the module..

    To those wondering :

    https://coderanch.com/t/748638/java/...module#3477276

Similar Threads

  1. Shell for module constructions (SMC)
    By pwipo in forum Java IDEs
    Replies: 0
    Last Post: March 3rd, 2021, 02:37 AM
  2. Error reading objects from file
    By prashant.6388 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: January 6th, 2014, 02:11 AM
  3. Mail Send Module Not Working
    By hashitagarwal in forum Java SE APIs
    Replies: 1
    Last Post: September 14th, 2012, 10:25 AM
  4. Beginner, Reading from file error
    By Lynce in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: October 27th, 2011, 06:31 AM
  5. How to write registration module
    By speedzojie in forum Java Theory & Questions
    Replies: 3
    Last Post: May 10th, 2010, 03:03 AM