About Question enthuware.ocpjp.i.v11.2.3026 :
Moderator: admin
-
- Posts: 62
- Joined: Fri Aug 07, 2015 2:16 pm
- Contact:
About Question enthuware.ocpjp.i.v11.2.3026 :
Why cant the a.b module reside in the .\ directory?
If a.b module needs to access something from the dir2, it will not work. content from dir2 must be placed under dir1.
But iif the a.b module does not need to access anything from dir2 directly it can be stored under the current directory.
If a.b module needs to access something from the dir2, it will not work. content from dir2 must be placed under dir1.
But iif the a.b module does not need to access anything from dir2 directly it can be stored under the current directory.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
>Why cant the a.b module reside in the .\ directory?
Because .\ is not specified in the module-path (i.e. -p).
In the given command, -p points to .\dir1. Therefore, the module must reside in this directory.
>If a.b module needs to access something from the dir2, it will not work. content from dir2 must be placed under dir1.
That's fine. The problem statement does not say anything about classes from the classpath.
>But if the a.b module does not need to access anything from dir2 directly it can be stored under the current directory.
The directory where the module is stored must be on the module-path. current directory is not on the module path in the given command.
Because .\ is not specified in the module-path (i.e. -p).
In the given command, -p points to .\dir1. Therefore, the module must reside in this directory.
>If a.b module needs to access something from the dir2, it will not work. content from dir2 must be placed under dir1.
That's fine. The problem statement does not say anything about classes from the classpath.
>But if the a.b module does not need to access anything from dir2 directly it can be stored under the current directory.
The directory where the module is stored must be on the module-path. current directory is not on the module path in the given command.
-
- Posts: 26
- Joined: Sun Jul 16, 2017 4:24 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
In the correct answer:
If it is inside a jar, then indeed the path should be \a\b\c, but that jar file should also be specified on the module path I believe?
Code: Select all
Main.class should be present in dir1\a.b\a\b\c directory or, if it is inside a jar, then its path should be \a\b\c.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
No, the jar need not be specified explicitly in the module-path. This is where module-path and classpath differ. In module-path, you just need to specify the directory that contains the jar (although you can specify the jar file also). In classpath, you need to specify the jar file.philippe wrote: ↑Sun Dec 15, 2019 2:49 pmIn the correct answer:
If it is inside a jar, then indeed the path should be \a\b\c, but that jar file should also be specified on the module path I believe?Code: Select all
Main.class should be present in dir1\a.b\a\b\c directory or, if it is inside a jar, then its path should be \a\b\c.
-
- Posts: 29
- Joined: Thu Aug 24, 2023 4:33 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
Hi,
I am little bit confused about this concept.
For the second option; I know that the -cp or --class-path option (.\dir2 in this case) is used for specifying the location of non-modular jars (or classes). If Main requires classes from a non-modular jar, those jars should be in dir2.
And for the third option; I know that the module path (.\dir1) should contain all the modules that the a.b module depends on. These can be in the form of modular JAR files, each containing a module-info.class.
It feels to me that both 2nd and 3rd options are correct and not 4th. What am I missing?
Plus, for the fourth option; what I know, the package structure inside the module (or jar) does not necessarily reflect the module's name. The Main class should be in the package a.b.c, but the directory structure would typically be dir1\a\b\c\Main.class (if unpackaged) or inside the jar under \a\b\c\Main.class. The module name (a.b) does not dictate the directory or package structure for the classes.
Why this is wrong?
I am little bit confused about this concept.
For the second option; I know that the -cp or --class-path option (.\dir2 in this case) is used for specifying the location of non-modular jars (or classes). If Main requires classes from a non-modular jar, those jars should be in dir2.
And for the third option; I know that the module path (.\dir1) should contain all the modules that the a.b module depends on. These can be in the form of modular JAR files, each containing a module-info.class.
It feels to me that both 2nd and 3rd options are correct and not 4th. What am I missing?
Plus, for the fourth option; what I know, the package structure inside the module (or jar) does not necessarily reflect the module's name. The Main class should be in the package a.b.c, but the directory structure would typically be dir1\a\b\c\Main.class (if unpackaged) or inside the jar under \a\b\c\Main.class. The module name (a.b) does not dictate the directory or package structure for the classes.
Why this is wrong?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
Main is part of a named module (name of that module is a.b) and, in the given command. Classes that belong to a named module cannot access nonmodular classes present in the classpath. So option 2 is wrong.
Option 3 is wrong and the reason is given in the explanation: It is not necessary to have a jar file of the module. In this case, dir1 may contain the module in the exploded format also.
Option 4 is correct. In exploded format, the class files must exist in a directory with the same name as the module name. Inside that directory, the package driven directory structure must also exist.
You might want to go through a good book to learn this topic.
Option 3 is wrong and the reason is given in the explanation: It is not necessary to have a jar file of the module. In this case, dir1 may contain the module in the exploded format also.
Option 4 is correct. In exploded format, the class files must exist in a directory with the same name as the module name. Inside that directory, the package driven directory structure must also exist.
You might want to go through a good book to learn this topic.
-
- Posts: 3
- Joined: Tue Oct 01, 2024 12:59 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
Given the correct answer: Main.class should be present in dir1\a.b\a\b\c directory or, if it is inside a jar, then its path should be \a\b\c.
but based on what I understand, with respect to the exploded format, the diretory of a.b could be a random name instead, as long as the module-info.java matches the module name inside the subdirectory of dir1, ?
but based on what I understand, with respect to the exploded format, the diretory of a.b could be a random name instead, as long as the module-info.java matches the module name inside the subdirectory of dir1, ?
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.3026 :
No, if you are using the exploded form, then the module must reside in a directory with the same name as the module name. So, if your module name is a.b, and if dir1 is specified in the -p option (i.e. -p dir1) then dir1 should contain a.b and a.b should contain the classes.
Who is online
Users browsing this forum: No registered users and 9 guests