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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
divx1989
Posts: 1
Joined: Sun Aug 04, 2019 7:53 pm
Contact:

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

Post 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?

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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 3663 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?

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

The following is the screenshot of my command line.
test2.png
test2.png (7.7 KiB) Viewed 3663 times
This is the correct result.
The generated directory structure in out is correct and the commands are correct as well.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 7 guests