Reputation: 87
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
Upvotes: 4
Views: 138
Reputation: 331
-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.
Upvotes: 3
Reputation: 13
There is no directory created when you do not specify the package!
all the .class
files will be created directly in the output folder
public class A{}
if you compile this to output folder ,
output/a.class
is created
Upvotes: 0
Reputation: 1500375
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.)
Upvotes: 4