Page 1 of 1
About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Wed Jan 06, 2021 10:06 pm
by teodorj
Code: Select all
java -p mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar -m com.abc.myapp.Main
why this option is incorrect?
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Thu Jan 07, 2021 12:21 am
by admin
It is missing the module name of the class that you want to execute.
-m should be followed by abc.myapp/com.abc.myapp.Main
and not just com.abc.myapp.Main
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Tue Mar 16, 2021 2:34 am
by minajev3
Sorry but where I can find real practical guide/ course about how to run all that stuff from commandline? cause just reading materials about modules isn't helping much, I want to try it myself.
I am getting ready to exam even though I started learning java from zero 3 months ago, and modules seems my weak point.
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Tue Mar 16, 2021 5:46 am
by admin
There are several books on modules as well as general Java books that explain modules in detail with examples. Even certification books explain them well.
I would suggest you to start with the modules chapter of
this book because it has simple working examples that are easy to understand and then go through the modules chapter of
this book because it covers the advanced topics for the exam.
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Tue Mar 16, 2021 6:15 am
by minajev3
hmmmm reading Study References
and quote " Thus, if your modular jar A depends on a non-modular jar B, you have to put that non-modular jar B on --module-path. You must also add appropriate requires clause in your module A's module-info, otherwise compilation of your module will not succeed. "
OK that's why for example this will fail right?
java -cp mysql-connector-java-8.0.11.jar;datalayer.jar -p myapp.jar -m abc.myapp/com.abc.myapp.Main
because myapp is named module and it would have no access to datalayer because it would be unnamed module right?
But here :
java -classpath mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar com.abc.myapp.Main
myapp works like unnamed module ? even though it is already named module.
or it is one of the - it is just works as exception situation?
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Tue Mar 16, 2021 8:27 am
by admin
No, the command "java -classpath mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar com.abc.myapp.Main" is the old non-modular way of executing Java code. It has nothing to do with modules. Observe that it does not use the -m flag. So, all module related information/rules are ignored.
The statement that you have quoted from study ref is talking about executing modules, which is applicable when you use the -m and -p options.
Re: About Question enthuware.ocpjp.ii.v11.2.3429 :
Posted: Tue Apr 20, 2021 11:13 am
by mohamed
The first answer which is putting everything on the classpath works partially because now it is not possible to load a service from a service provider.