Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac -d

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use this to compile a class but why do I not see the .class version being set into the appropriate directory? When I do this, I get no .class file. If I compile without the -d, the .class version will end up in the same directory as the .java version.
 
Ronald Schindler
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Into which directory are you trying to put the class file when compiling?
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't seem to make a difference. If I have a package com.test in the class and I try to compile with javac -d com\test cl.java it will say something like you can't compile into com\test\com\test. All I want to do is compile a class from the dos prompt and see it end up in the correct package/directory.
Paul
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-d is going to be the "base" directory. Like, the same thing that you'd use in CLASSPATH.
So if you have a class called MyJunk in package "com.foo", and you want the thing to end up in /home/devel/classes/com/boo/MyJunk.class then you compile with javac -d /home/devel/classes MyJunk.java
and you'd execute it with
javac -classpath /home/devel/classes com.foo.MyJunk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic