Page 1 of 1

[HD Pg 0, Sec. 16.2.1 - compiling-a-module]

Posted: Mon May 20, 2024 6:50 am
by divx1989
Hi,

Running the command for compiling the module given in the example:
javac -d out --module-source-path src --module simpleinterest

resulted in the following directory structure:
out
└───simpleinterest
│ module-info.class

└───simpleinterest
└───simpleinterest
SimpleInterestCalculator.class

This means that we end up with an extra folder in our module, and the command to run this also needs to be modified accordingly.
Moreover, whenever this project is opened in an IDE, it gives an error saying that module-info.java needs to be in the src directory, not simpleinterest.
Can this be elaborated upon?

Re: [HD Pg 0, Sec. 16.2.1 - compiling-a-module]

Posted: Mon May 20, 2024 10:32 am
by admin
It is not clear from your illustration which extra folder are you refering to. Please see the folder structure that I go after compiling using the same command:
test.png
test.png (14.29 KiB) Viewed 3662 times
out is the output directory. Inside out, you should have simpleinterest directory (which is the module directory for simpleinterest module) and inside out/simpleinterest you should have module-info.class
That's what the attached image shows.

Which IDE are you using?

Re: [HD Pg 0, Sec. 16.2.1 - compiling-a-module]

Posted: Mon May 20, 2024 10:37 am
by admin
The following is the screenshot of my command line.
test2.png
test2.png (7.7 KiB) Viewed 3662 times
This is the correct result.
The generated directory structure in out is correct and the commands are correct as well.

Re: [HD Pg 0, Sec. 16.2.1 - compiling-a-module]

Posted: Mon May 20, 2024 10:42 am
by admin
>it gives an error saying that module-info.java needs to be in the src directory, not simpleinterest.
IDE's may follow their own directory structure but as per the specification, module-info.java must be in the module directory. The module directory is simpleinterest (not src). The src folder is a source folder for all modules, not for just simpleteinterest module.