0

I'm trying to learn java 9 modularity.

In my project I have 3 modules - 1. com.red30tech.database 2. com.red30tech.cache 3. com.red30tech.backend.

1 is depend on 2, 3 and 2 is depend on 3.

The source code of the project is here.

when I try to compile the project I get below error.

Exercise1> javac -d mods/ --module-source-path src $(find src -name "*.java")
src/com.red30tech.backend/com/red30tech/backend/Processor.java:10: error: package com.red30tech.cache does not exist
            db = com.red30tech.cache.api.Cache(db);
                                        ^
1 error

If I comment this line, then the compilation is successful.

I've exported the package in module cache here and added the requires in backend module here.

Any reason why my package is not recognized in backend module?

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
user51
  • 8,843
  • 21
  • 79
  • 158
  • Please update the question with respective code lines to make it an [MCVE](https://stackoverflow.com/help/mcve). It's really poor to navigate to all those links to see what the construct is and then debug if required. – Naman Apr 09 '18 at 06:15
  • Change it to `new db = com.red30tech.cache.api.Cache(db)` and I assume it will compile. I agree the error message from `javac` is confusing in this case. – Alan Bateman Apr 09 '18 at 06:16
  • @AlanBateman I guess you mean `db = new com.red30tech.cache.api.Cache(db)`? – Naman Apr 09 '18 at 06:18
  • 1
    Yes, I he's missing `new` which makes it looks like it's a static method on class api, hence the apparently misleading message from javac. – Alan Bateman Apr 09 '18 at 07:44
  • indeed I did a dumb mistake I'm missing `new` while creating object :(. I will close this question – user51 Apr 09 '18 at 16:47

0 Answers0