This week's book giveaways are in the Angular and TypeScript and Web Services forums.
We're giving away four copies each of Programming with Types and The Design of Web APIs and have the authors on-line!
See this thread and this one for details.
Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Possible errata in OCP guide book for java 11

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe there is a syntax mistake in the following while specifying the path for the jar file creation, there should be no hyphen before the drive path, just simple space.
I have tried on the command prompt on windows 10. Maybe I am wrong please confirm, I just learning, so I may be wrong.

This is chapter 1.

Creating a JAR File


jar -cvf myNewFile.jar .
jar --create --verbose --file myNewFile.jar .
Alternatively, you can specify a directory instead of using the current
directory.
jar -cvf myNewFile.jar -C dir . <<--- the extra hyphen throws error.   ": no such file or directory"


jar -cvf myNewFile.jar C dir   <<-- removed hypen, creates jar successfully.

 
author & internet detective
Posts: 39760
797
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should definitely be a hyphen there.  The docs even show it as -C

One thing to try is deleting the hyphen and re-typing.it. Maybe you have a "Word" dash instead of a regular dash?

I'm surprised it works without the hyphen!
 
Marshal
Posts: 66980
255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely after -...f the tool is interpreting C as the name of a file.
 
Dinkar Joshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried again, please find below:

C:\Users\DJ\OCP>jar -cvf myNewFile.jar C:\Users\DJ\OCP
added manifest
adding: Users/DJ/OCP/(in = 0) (out= 0)(stored 0%)
adding: Users/DJ/OCP/OCP1/(in = 0) (out= 0)(stored 0%)
adding: Users/DJ/OCP/OCP1/pack1/(in = 0) (out= 0)(stored 0%)
adding: Users/DJ/OCP/OCP1/pack1/Classa.class(in = 192) (out= 161)(deflated 16%)
adding: Users/DJ/OCP/pack1/(in = 0) (out= 0)(stored 0%)
adding: Users/DJ/OCP/pack1/Classa.java(in = 46) (out= 44)(deflated 4%)
adding: Users/DJ/OCP/pack2/(in = 0) (out= 0)(stored 0%)
adding: Users/DJ/OCP/pack2/ClassB.java(in = 165) (out= 130)(deflated 21%)
adding: Users/DJ/OCP/thi.jar(in = 140885) (out= 140834)(deflated 0%)
adding: Users/DJ/OCP/Zoo.java(in = 410) (out= 216)(deflated 47%)

C:\Users\DJ\OCP>
Capture.PNG
[Thumbnail for Capture.PNG]
 
Marshal
Posts: 24820
60
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But as the documentation says the "-C dir" part is optional. In this case you've left it out, which is perfectly acceptable. You just have "C:\Users\DJ\OCP" as the files to be archived.
 
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!