Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Compiling jpms modules in Windows cmd  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am following the Lynda.com tutorial on "Learning Java 9 Modularity: Implementing the modular structure

I am trying to follow the examples.  To compile the example, Instructor shows it in Linux by using 'Find' command ext, but I am using Windows Command prompt.

For example this is what the Instructor is using for compilation:

javac -d ./mods/ --module-source-path src $(find src -name "*.java")

When I use the above line in Windows cmd I get the following error: "error: invalid flag: $(find".  If I enclose the entire section in brackets in quotes then I am getting: invalid flag: $(find src -name *.java)

Can anyone please suggest how to run the above line in Windows cmd?

Thanks  

 
Marshal
Posts: 61727
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The $(...) part is a separate instruction. The find program looks for files matching some criteria. In this case, it is those in the src directory whose name matches anything.java. Then the $(...) collects all the results and passes them back to the terminal as a list of files, which the javac tool uses as arguments. I don't think you are going to get that to work on a Windows® box, I am afraid. You may have to look at each package/folder and compile everything the hard way with javac ... myPackage/*.java

And welcome to the Ranch
 
Sulo Az
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer.  I think creating vm with Linux wouldn't be a bad idea, but for now will compile them separately.  And thank you for welcoming me.
 
Sulo Az
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still experiencing the problem with this.  I can only compile single .java files.  But I can't compile some of the .java files because they include "import package" in them and I am getting the error.  

Is there a way to compile single .java file from one package that depend on another package ?
 
Sulo Az
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I found the workaround by using all three packages in one javac command, thank you.
 
Campbell Ritchie
Marshal
Posts: 61727
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds a good workaround; you can often compile multiple files when you can't compile them individually.
 
Sulo Az
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I have to say it is a bit of a pain.  Sometimes it wouldn't work if I have, for instance, more than one module-info.java file under the same parent directory which requires a package from a different module - it's a nightmare.  Especially when trying to follow the video tutorial that is shown in Unix.  
 
Campbell Ritchie
Marshal
Posts: 61727
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it does sound like a pain. If you don't use an IDE or Ant for compiling, consider writing an executable .bat file. On Unix/Mac/Linux, you would use a shell script instead.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!