What's the deal with javac command?
Hi,
I am a few days old in using the Java programming language. I have written very basic arithmetic programmes. Tow classes in the same package; one class calls the other. Java cannot find the called class.
So, I just ask how does the javac command work in relation to class/package location?
I will appreciate it if someone could tell me where to get simple explanations or documentations of the relationship between the javac command, package and classpath.
Thanks for your help,
ue-Joe.
[528 byte] By [
ue_Joea] at [2007-11-27 4:15:15]

[url= http://java.sun.com/j2se/1.5.0/docs/tooldocs/]JDK Tools and Utilities[/url]Regards,Tim - a Really Useful Link ?
Thanks for your response. I have tried the javac commands in this link before, they just did not work. I am using JDK1.6.10. Does this JDK know the commands in this link? I am beginning to think otherwise or is it just something wrong with me?ue-Joe.
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html
I think now I should rephrase the question: Is JDK1.6 compliant with the commands in the suggested links? Thanks,ue_Joe
Well, maybe you should, put it another way.
List exactly where your source files are (which file in which directory), then display the package and (relevant) import lines of each of those source files, then list exactly where the class files are to be written (just the root of the class tree), then display the exact command you try, and, finally, give the exact error message you get.
Maybe then we can help you. Simply saying "It didn't work" due to "packages" tells us absolutely nothing, and you will get the answers you have been getting.
> I think now I should rephrase the question: Is JDK1.6 compliant with
> the commands in the suggested links?
The way JDK tools look for resources hasn't changed for a while. I don't think there is a significant difference between 1.5 and 6.
You should focus on the "Setting the Classpath" (especially the "Understanding the class path and package names" section) and "How Classes are Found" pages.
(Here is the same link for Java 6 anyway: [url=http://java.sun.com/javase/6/docs/technotes/tools/index.html]JDK Tools and Utilities[/url])
And in case you still encounter problems, please follow the instructions described in reply#5 for your next post.
Thanks guys. Apology for the delay in responding. I went to lectures. Anyway, I have just gone through links and carefully compared the commands with my javac commands. I made corrections and I was able to compile the programme. This is not to say that I have mastered the javac commands. The next thing is that I am not able to run the programme. Below, are the commands that I issued and the responses that I got.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\user>cd C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\joeweb
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\joeweb>javac src\MathClient.java
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\joeweb>java scr\MathClient
Exception in thread "main" java.lang.NoClassDefFoundError: scr\MathClient
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\joeweb>
More help please!
ue_Joe.
The parameter for java (application launcher) is the fully qualified class name, not a file name. That is dot-separated package structure followed by class name.
For example: my.package.MyClass
The class file is then found based on the class path. This process of finding classes is well explained in the provided docs ("Setting the Classpath" and "How Classes are Found" in the general section). Understanding class path is the key to understanding javac and java apps.