• 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
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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: 10136
214
  • Mark post as helpful
  • send pies
  • 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: 10136
214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, why are you enclosing the source file name in brackets? Don't do that.
 
Sheriff
Posts: 5931
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 17
  • Mark post as helpful
  • send pies
  • 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.
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!