By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,726 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

Package and compiling

P: n/a
Isa
Hi!
I have a question about the package and Java class files. I hope someone can
answar me. When I compile a java source file with a package statement I
expect that the compiler should create the package directories and put the
class file there.
For example:

package homecompany.utilies;
public class graph{
....
}

The command C:\ javac graph.java compiles and create the class file
graph.class
in the same directory. I suppose that the class file graph.class should
placed in the
directory C:\homecompany\utilies\, but it does not. The development env. is
windows xp with Java SDK 1.4_2.

Thanks to any comment
Isa

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


"Isa" <is**************@comhem.se> wrote in message
news:_U********************@newsc.telia.net...
Hi!
I have a question about the package and Java class files. I hope someone can answar me. When I compile a java source file with a package statement I
expect that the compiler should create the package directories and put the
class file there.


Wrong.
http://java.sun.com/docs/books/tutor.../packages.html
--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
Jul 17 '05 #2

P: n/a
"Isa" <is**************@comhem.se> wrote in message news:<_U********************@newsc.telia.net>...
Hi!
I have a question about the package and Java class files. I hope someone can
answar me. When I compile a java source file with a package statement I
expect that the compiler should create the package directories and put the
class file there.
For example:

package homecompany.utilies;
public class graph{
...
}

The command C:\ javac graph.java compiles and create the class file
graph.class
in the same directory. I suppose that the class file graph.class should
placed in the
directory C:\homecompany\utilies\, but it does not. The development env. is
windows xp with Java SDK 1.4_2.

Thanks to any comment
Isa


Mapping between java package and system directory structure is
not automatic default. See Java Language Specification chapter 7.
Jul 17 '05 #3

P: n/a
Isa wrote:
Hi!
I have a question about the package and Java class files. I hope someone can
answar me. When I compile a java source file with a package statement I
expect that the compiler should create the package directories and put the
class file there.
For example:

package homecompany.utilies;
public class graph{
...
}

The command C:\ javac graph.java compiles and create the class file
graph.class
in the same directory. I suppose that the class file graph.class should
placed in the
directory C:\homecompany\utilies\, but it does not. The development env. is
windows xp with Java SDK 1.4_2.

Thanks to any comment
Isa


First, get the JDK documentation from Sun. Part of the documentation is
"Tool Documentation" and that will tell you lots of things about javac,
java, etc.

What you want is the -d option to javac.

Ray
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.