• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about tools.jar??

 
Chen SanHau
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Sun's doc:
The tools classes in tools.jar are only used to run javac and javadoc.
Does it mean that:
In Windows,when I run
C:\>javac HelloWorld.java
The JVM will find javac.exe in the SDK's/lib/tools.jar
Not the program in the SDK's/bin/tools.jar
Do it right?
I need your help!
Thanks in advance!!
[ March 22, 2004: Message edited by: ChenSanHau ]
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's safe to say that the tools (under the tools section in the sdk documentation) are actually Java programs located in the tools.jar file. So, when you invoke any of these things, they are merely a wrapper for programs in the tools.jar file.
However, since this is the first time I've heard any sort of special attention on the direct usage of tools.jar, I'm going to say that this is a bit of an advanced topic. I would recommend that you just use the OS programs supplied in the bin directory, and leave it at that.
That is, unless you have some real reason for devoting your attention to the tools.jar file--which you should feel free to explain so we can be of further assistance.
 
Chen SanHau
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ask this question just for research.You can see this:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html
http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html#srcfiles
My test:
I change SDK's/lib/tools.jar to SDK's/lib/mytools.jar
When I run java.exe, I get running OK.
When I run javac.exe or javadoc.exe, I get
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
What I want to know is, there also are java.exe and javadoc.exe in SDK's/lib. I guest when I run javac or javadoc, JVM finds it under
SDK's/lib/tools.jar.
If it's true, at what time does javac or javadoc in SDK's/lib use??
It seems that these two programs in SDK's/lib are of no use.
Am I right??
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No -- inside the jar files there are only Java class files and supporting files for who knows what. The EXE files are just a wrapper to invoke the tools. EXE files are invoked by the operating system and so have nothing really to do with Java. There won't be any corresponding EXE files in the tools.jar file--just the corresponding classes with main functions to invoke by javac, etc.
I believe that the tools.jar file can be used within other programs to compile programs, etc. For instance, Tomcat will use the tools.jar file to compile translated JSP pages, and so forth.
In your case, I think you're getting a ClassNotFoundException because you haven't set the tools.jar file to be part of your classpath when you are invoking whatever program you are trying to invoke. (If I remember correctly, the doc says something about it, but I didn't read it too well).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic