About Question enthuware.ocpjp.ii.v11.2.3429 :

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

Moderator: admin

Post Reply
teodorj
Posts: 33
Joined: Tue Jun 19, 2018 10:27 am
Contact:

About Question enthuware.ocpjp.ii.v11.2.3429 :

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

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

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

Post 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
If you like our products and services, please help us by posting your review here.

minajev3
Posts: 18
Joined: Fri Feb 05, 2021 3:37 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

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

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

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

Post 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.
If you like our products and services, please help us by posting your review here.

minajev3
Posts: 18
Joined: Fri Feb 05, 2021 3:37 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

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

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

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

Post 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.
If you like our products and services, please help us by posting your review here.

pavel.gurinovich
Posts: 13
Joined: Mon Nov 18, 2019 4:59 am
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

Post by pavel.gurinovich »

Seems like there is misprint, missing 'u' letter in word assuming.
Assuming that com.abc.myapp.Main is the main class of your applicati...

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

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

Post by admin »

You are right. Fixed.
thank you for your feedback!
If you like our products and services, please help us by posting your review here.

mohamed
Posts: 3
Joined: Sun Apr 11, 2021 5:00 pm
Contact:

Re: About Question enthuware.ocpjp.ii.v11.2.3429 :

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

Post Reply

Who is online

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