• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

“javac -d” command from the console generates duplicate folder

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do know that you need the  "javac -d "  command from the console to generate the .class file but I am having trouble writing the path correctly. I have a source code file in javaprojects\src directory, I wish to compile it and have its .class file be created and stored in a separate folder named javaprojects\bin

when using the command:

C:\Users\userNAME\javaprojects\src> javac -d bin   HelloWorld.java

When I compile the .java file the .class file is created along with a new duplicate "bin" folder:

javaprojects\bin\src\bin HelloWorld.java


I do not know what is the proper way to just create the .class file in the folder I need it to be create it at. I have searched
but I am not finding anything on the matter. Any help would be greatly appreciated, thank you.

EDIT:
I'd like to thank you all for the helpful replies. For some reason or another I am unable to post any replies!

EDIT2:
Tried both methods that were advised and they work, thank you again. Now though my issues is that whatever named package
I write in my source code file, e.g: "package mypackage;" , is created within the "bin" folder after I compile the HelloWorld.java file:
javaprojects\bin\mypackage HelloWorld.class
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need the -d option to generate class files, but it's a good habit.

What do you mean by duplicate folder? Windows can't have two folders with the same name at the same location.

Where do your class files appear? They should be generated inside the bin folder.
 
Stephan van Hulst
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, why are you enclosing the source file name in brackets? Don't do that.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:

C:\Users\userNAME\javaprojects> javac -d bin src/HelloWorld.java

or

C:\Users\userNAME\javaprojects\src> javac -d ..\bin HelloWorld.java
 
ethan crown
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Try this:

C:\Users\userNAME\javaprojects> javac -d bin src/HelloWorld.java

or

C:\Users\userNAME\javaprojects\src> javac -d ..\bin HelloWorld.java




Thank you very much. this is exactly what I needed to understand as to why I was getting the kind of errors and or outcomes I was not expecting.
 
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic