• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

jsdom error? not sure what's going on here

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. When run my code I get the following error:


Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /Users/tedgress/Downloads/jdom-2-2/jdom-2.0.6-contrib.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: TestIds.class found in top-level directory (unnamed package not allowed in module)



I don't know what this error means?
 
Sheriff
Posts: 3914
542
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:

Java compiler wrote:TestIds.class found in top-level directory (unnamed package not allowed in module)


Is your class in a package?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It wasn't originally but I made a package for it and a new class inside the package. I deleted the package with no name. Not sure what to do from here.
 
Sheriff
Posts: 17071
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:I deleted the package with no name.


I’m curious as to how you think you managed to do that.
 
Marshal
Posts: 76406
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that means deleted the class from the unnamed package. In which case, did you delete the XXX.class files too?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

Ted Gress wrote:
I deleted the package with no name.


I’m curious as to how you think you managed to do that.

Ted Gress



There was a "default"package with a Main.java inside it. I created a package named "origin" with a Main.java class in it. I deleted the Main.java file from the default package and then deleted the default package.
Doesn't that make sense? I read that those defauit packages can cause the error that I was getting. However, after all that I am still getting that module error.
 
Marshal
Posts: 27367
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't see the part where you said "... and I recompiled the Main.java file in the package and then rebuilt the jar file to include that package/Main.class file." If you didn't do that, then that's where you should go from here.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand. After I did what I said I did I saved the java files and built the project. Then I tried to run it and got the same error? Is there something else I should be doing??
 
Paul Clapham
Marshal
Posts: 27367
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're still getting an error message which says "unnamed package not allowed in module" then yes, there is more to do. Your description of what you did doesn't say that you put a "package whatever" declaration at the top of your Java source code, for example. I'm just guessing here because you're giving us IDE-related descriptions of what you did and not Java-related descriptions.
 
Paul Clapham
Marshal
Posts: 27367
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, you keep referring to your class as "Main.class" whereas the error message refers to "TestIds.class".
 
Ron McLeod
Sheriff
Posts: 3914
542
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm .. it looks like TestIds.class is actually in a third-party jar: jdom-2.0.4-contrib.jar (not the same version)
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TestIds.class is somehow associated with jdom, although how it is is beyond my expertise. I'm talking from an IDE perspective because the error is occuring in an IDE. As of right now, there is no top level "defaujlt"  package, i.e.., every part of the hierarfchy is in a package.I refer to Main.class because from what I googled the issue was arising from the default package and file iwthin and I had a default package with a Main.java in it so the error I assumed was with that, not TestIds.So like I originally posted (minus the type) I think it has something to do with jdom.

Thankds


Ted
 
Paul Clapham
Marshal
Posts: 27367
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:So like I originally posted (minus the type) I think it has something to do with jdom.



Yes, you're right. You reasonably assumed it was your problem -- that's always a good assumption to start with. And we all went along with that idea because it's much more likely to be the beginner's problem rather than the widely-used open-source product's problem.

But it looks like you can't use that version of JDOM in a Java environment which uses modules. However when I search the web for that sort of issue -- you'd think it would be all over the web by now -- I don't find anything. So maybe your IDE is building the project wrong in terms of modules? If that sounds vague it is because I don't have any experience with that sort of thing.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The thing is that that environment is a clone of an older eclipse workspace and this is an eclipse workspace with an identical set of jars for jdom. It makes me want to believe that the problem
is not with jdom (a lot of people have used it without this problem - should be all over the internet) but it is somehow something different with this build of eclipse and the original builds
copy of eclipse. But this is definitely way out of my league. Anybody else have any suggestions?

 
Ron McLeod
Sheriff
Posts: 3914
542
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:The thing is that that environment is a clone of an older eclipse workspace and this is an eclipse workspace with an identical set of jars for jdom


Is the older environment also using Java 9, or is it using something older (Java 8, 7, etc.)?
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think the older version was using Java 9. This was coded three years ago. How would I find out what the version was for the older build? I know if I do java -version on my computer now it comes back Java version 13
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any more ideas? Suppose it was an older version of Java (the original code). What do I do about that to get it to build and fix the problem??
 
Campbell Ritchie
Marshal
Posts: 76406
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try opening one of the XYZ.class files with a hex. editor; you can find the version in one of the bytes near the beginning (well, subtract 0x2c from it).

[edit}This Wikipedia page should tell you which byte you are looking for.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not going to work since I don't have any of the class files built from the old eclipse build. Any other ideas? I read something about deleting the module file?
 
Ron McLeod
Sheriff
Posts: 3914
542
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ted Gress wrote:Any more ideas? Suppose it was an older version of Java (the original code). What do I do about that to get it to build and fix the problem??


The problem is that the TestIds.class is located in the default package (the project root), which appears to not be compatible with the Java Platform Module System used in Java 9 and later (I have not had to dig in to this myself).

Some options would be:
   - use a Java 8 build environment
   - rebuild the jar yourself from source, removing the problematic class, or moving it to a proper package
   - remove the problematic class from the existing jar (a jar file is just a zip file)
   - wait for the project to release a version which is compatible with Java 9+
 
Ron McLeod
Sheriff
Posts: 3914
542
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:remove the problematic class from the existing jar (a jar file is just a zip file)


I just used 7z to remove the unwanted files from jdom-2.0.6-contrib.jar without any issues.  Maybe give that a try and see if it works-around your problem.
 
Ted Gress
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ron. That did the trick.
 
get schwifty. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic