• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Start method error without "module-info-java", then boot-layer error with the module file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started Java and am running on Java 12. When I try running my code I get this extremely long error block.


That error pops up when I delete the "module-info-java" file I created. However, when I add the file I get a shorter error message.
This is what is inside the module-info-java file.


And when I run the program with the module-file, then I only get this error message.


I've been learning Java for a little bit and always hve issues arise deriving from modules / packages / Java version etc. Can someone explain or help breakdown modules / packages? Or just help me figure out why this program won't run. Thank you for taking time out of your day / night to read this and help me. Cheers!
 
Saloon Keeper
Posts: 10539
224
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add the module-info.java file to your project, the error message tells you exactly what's wrong: Your module descriptor declares that the 'sample' package is open for reflective access, but your module doesn't contain any package named 'sample'.

Without the module descriptor, the Java runtime manages to get past the module checking step, but fails in Main.java with a NullPointerException. This could have any reason, and we can't help you without seeing the source file.

Please also tell us how you are building and running your project.
 
Luka Sarich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:When you add the module-info.java file to your project, the error message tells you exactly what's wrong: Your module descriptor declares that the 'sample' package is open for reflective access, but your module doesn't contain any package named 'sample'.

Without the module descriptor, the Java runtime manages to get past the module checking step, but fails in Main.java with a NullPointerException. This could have any reason, and we can't help you without seeing the source file.

Please also tell us how you are building and running your project.



Thanks for the response Stephan. I downloaded the ZIP file because I wanted to follow along for my course. When I unzipped it, it looked like this.

So I just imported the "s3v1" file using IntelliJ because a classmate said, "It had all the necessary files". Prior to this I imported the whole "project" file and had even more problems.

I know i'm asking really fundamental questions and the answer is probably super simple. Thanks for helping me out!

Edit : It's also probably worth noting that when I go in to Project Structure in IntelliJ, it says that the out folder is excluded, you can see that here.
 
Stephan van Hulst
Saloon Keeper
Posts: 10539
224
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does it list all the sub-folders of 'out' as source folders? That doesn't look right to me.

Anyway, I can see that the application doesn't contain a 'sample' package, so your module descriptor is wrong. Just remove the 'opens' declaration and keep the two 'requires' declarations.

We still need to see the Main.java file before we can help you with the NullPointerException. But please don't post an image of it. Post it here as text and surround it in code tags [code]like this[/code].
 
Luka Sarich
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Why does it list all the sub-folders of 'out' as source folders? That doesn't look right to me.

Anyway, I can see that the application doesn't contain a 'sample' package, so your module descriptor is wrong. Just remove the 'opens' declaration and keep the two 'requires' declarations.

We still need to see the Main.java file before we can help you with the NullPointerException. But please don't post an image of it. Post it here as text and surround it in code tags [code]like this[/code].



When I remove the 'opens' declaration and try running then I get this error :


Here is the Main.java file :
 
Stephan van Hulst
Saloon Keeper
Posts: 10539
224
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's important to learn how to read stack traces. You see that it contains several lines that start with "Caused by:". The last one is the root cause. Then the first line of that exception stack trace tells you exactly what's wrong:

JavaFX can not launch your application because your module does not expose the package containing your main class to the outside world. You fix this by using the following module-info:
 
Seriously? That's what you're going with? I prefer this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!