This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of "." in classpath

 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw this in a search result.
This leaves me with a question: if "." is in classpath, does this mean that whatever folder I have stored the *.java file is where the *.class will be compiled too?
Additionally, is there a way to get a windows system to compile *.class files to whatever folder you are currently working in automatically? Having to adjust environment variables continuosly is a pain in the - well you know.
Maybe I am missing something... :roll:
TIA
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This leaves me with a question: if "." is in classpath, does this mean that whatever folder I have stored the *.java file is where the *.class will be compiled too?
Additionally, is there a way to get a windows system to compile *.class files to whatever folder you are currently working in automatically? Having to adjust environment variables continuosly is a pain in the - well you know.


1) classpath has absolutely nothing to do with compilation. It has to do with runtime. The dot means that whichever folder you are in is automatically included in your (runtime) classpath.

2) You can use the javac flag '-d' with a dot. For example
javac -d . YourClass.java
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ April 14, 2004: Message edited by: Donald R. Cossitt ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) classpath has absolutely nothing to do with compilation. It has to do with runtime. The dot means that whichever folder you are in is automatically included in your (runtime) classpath.
The CLASSPATH absolutely gets involved with compilation. Its value is used by the compiler to locate class dependencies needed during compilation.
The CLASSPATH has nothing to do with the placement of compiled classes. By default, they're placed in the same directory where the source file is located. As mentioned, you can change this placement location by using the -d switch when compiling.
[ April 14, 2004: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic