I am a newbie in java I Want to know that what is the default directory for packages in java ? I Mean if i compile a java file which contains a package statement,and i compile it without using -d
option in javac
command,then where will be the package created ? eg.
package test;
class Test{}
and compile it using javac Test.java
then where will be the package created?
Thanks
If you don't specify -d
, the class file will be created in the same directory as the source file.
That's fine if you're already storing your source in a directory structure matching your package structure (and if you're happy for your source and class files to live in the same place) but if your source structure doesn't match your package structure, you'll basically end up with class files in locations where they can't sensibly be used.
Personally for anything other than quick throwaway (usually Stack Overflow :) code I would make the following suggestions:
src
) matching package structurebin
or out
or classes
)(Sorry, misread the question to start with.)
-d
option in javac
command is use to specify where to generate the class file,if you don't specify it,then the .class
file will be created in the same directory where your .java
file is present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With