• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

“Sybex” - 1Z0-815 - Chapter 1 page 24

 
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The section headed "Running a Program in One Line with Packages" states "You can use single-file source-code programs from within packages as long as they rely only on classes supplied by the JDK". This is incorrect. You can use user defined classes too.
 
Bartender
Posts: 3668
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,

While we appreciate the errata you reporting, this is general Java certification forum, and not all people have the book. To add more value to your post, could you share for example your scenario -- source .java code and small demo how you run it from command line.

I am pretty sure many readers would appreciate these details. My guess is that the "user defined classes" must reside in the same source (either peer level or inner classes), no classes from user defined modules. Can we discuss in that direction?

Cheers,
MZ
 
Dean Kirby
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please see the following example
chapter1.jpg
[Thumbnail for chapter1.jpg]
 
Mikalai Zaikin
Bartender
Posts: 3668
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see, yes, so you have the Boo.class precompiled

Would be even better if you use Code button on the buttons panel, so other people can try your code. Screenshot is good, but own practice is the key for exam success 8)

MZ



 
Dean Kirby
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Writing code helps in the learning process. Copy and pasting someone else' code doesn't really tick that box.
 
Marshal
Posts: 71724
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Writing code is part of your learning, yes. But seeing the exact code in text format allows us to verify the errors you might have found.
 
Mikalai Zaikin
Bartender
Posts: 3668
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at JEP 330 (which should be the primary source of the information for this feature) I see it can use class path option and module path option in command line, so I am really puzzled what authors mean about depending on JDK classes only.

The source file is compiled in context of unnamed module (which can access unnamed module classes and/or named modules classes) and ran as well in context of unnamed module (which allows to access classpath and/or module path classes).

MZ
 
author & internet detective
Posts: 40386
821
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is really interesting. I did not know you could do that. I checked both the spec and JEP 330. You are correct.

Good find!

(Incidentally since file source code execution is not on the exam. We covered it to make running the examples easier when studying for the exam)
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic