Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Order for java files while compiling module

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OCP Java SE 11 Programmer I Study Guide(Boyarsky and Selikoff ), Chapter 11 - Page 466 (Order Matters!)

as per the text in book, while compiling the module using javac command, order of the java files matters. module-info.java can not be listed as first file if module is exporting some package and there is no class file exist for the package.

I ran the command with module-info.java as the first file, without any exported package/class file already existed and not getting the error.

Also as the oracle java 13 documentation (https://docs.oracle.com/en/java/javase/13/docs/specs/man/javac.html) order does not matter. I couldn't find the documentation for java 11.

The order of source files specified on the command line or in an argument file is not important. javac will compile the files together, as a group, and will automatically resolve any dependencies between the declarations in the various source files.

Please check
 
author & internet detective
Posts: 40239
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sachin,
I agree that order shouldn't matter. However, it did when I was testing the example. So I put a note in the book for anyone who ran into the same issue.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic