0

When executing a simple programm that aims to write a string into an ods-File, i get an error in eclipse.

Here's the error:

java.lang.module.FindException: Unable to derive module descriptor for /home/benutzer/Documents/Java/Eclipse/FNetParser/src/jOpenDocument.jar Caused by: java.lang.module.InvalidModuleDescriptorException: JDOMAbout$Info.class found in top-level directory (unnamed package not allowed in module)

Now here's how I got there: I wrote a class that uses the jopendocument-1.5.rar library to write a string into a cell in an .ods-file. I downloaded the jar here: https://jopendocument.org/download.html (I downloaded version 1.5) and the code looks like this:

import java.io.File;
import java.io.IOException;
import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;


public class SpreadSheetHandler {
    
    public static void main() {
    
        SpreadSheetHandler ssh = new SpreadSheetHandler();  
        ssh.writeStringToCell("L1", "Test");
            
    }
        
    
    public void writeStringToCell (String str_cell, String str_value) {
        
        File odc_WpDaten = new File("/home/benutzer/Desktop/Aktien/20230103_Aktienliste.ods");
        
        //odc_WpDaten.loadFrom("/home/benutzer/Desktop/Aktien/20230103_Aktienliste.ods");
        
        Sheet sht_WpDaten;
        try {
            sht_WpDaten = SpreadSheet.createFromFile(odc_WpDaten).getSheet("Sheet1");
            
sht_WpDaten.getCellAt(str_cell).setValue("str_value");
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

All the programm is supposed to do is open an .ods file and write "Test" in cell L1. That's it.

I have added the jopendocument library to my project like other libraries before (Add library..., then add to build path...) I have also aligned to names of the jar file (renamed the .jar file "jopendocument.jar") and of the entry in the module-info.java file. I still get the error.

The content of module-info.java looks like this:

/**
 * 
 */
/**
 * @author benutzer
 *
 */
module FNetParser {
    requires jOpenDocument;
}

It doesn't look like a coding problem to me. More like some issue with setting this ominous "module descriptor" in eclipse. Does anyone know where i can find the "module descriptor", that is mentioned in the error message?

I the module-info.java, "jopendocument" is underlined, when i hover over it, the tooltip reads: "Name of automatic module "jopendocument" is unstable. It is derived from the module's filename.

Holger
  • 1
  • 1
  • 2
    It looks like that jar is not compatible with the Java module system. You can stop using modules by deleting the `module-info.java` file. – greg-449 Jan 08 '23 at 17:05
  • Welcome! [Here's how to ask a proper "Where's the bug / Fix my code" question](https://meta.stackoverflow.com/a/253788/11107541). Can you please read it and apply what you learn to improve your question? Can you please provide a [mre]? See [ask] for further guidance. Can you please [edit] to convert your images of text into actual text? [See here](https://meta.stackoverflow.com/a/285557/11107541) for why. See [/editing-help#code](/editing-help#code) for how to format code blocks. – starball Jan 08 '23 at 21:05
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 09 '23 at 02:31
  • @greg-449: I need the module to access the .ods file. If you have another way of working with .ods files, please let me know. – Holger Jan 09 '23 at 07:51
  • @starball: I added the code and some more info on where i got the library, but i'm not really sure the code is the issue here. – Holger Jan 09 '23 at 07:53
  • Yes it's good that you added where you downloaded it from and what version you downloaded. You just need to provide _just_ enough information for others to reproduce the issue. That doesn't always necessitate adding code, but it usually does. In this case, maybe it didn't. – starball Jan 09 '23 at 08:02

0 Answers0