aspose file tools*
The moose likes Beginning Java and the fly likes Help with compiling packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with compiling packages" Watch "Help with compiling packages" New topic
Author

Help with compiling packages

Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Help please ... this is driving me crazy. I know this should be simple but I've read all the docs I can find and I'm still missing something.
I have two files:


The files are located in the following directories:
d:\java\jeg\examples\TestPkg.java
d:\java\jeg\examples\test\InsideTest.java
My CLASSPATH environment variable is not set to anything. I'm using JDK1.3 and all the docs I've found say the default classpath is the current directory (The Java Programming Language Compiler
I compile InsideTest with no problem from the example directory:
javac test\InsideTest.java
Running javap -c test.InsideTest gives me:

I have tried compiling TestPkg.java from within the examples directory with the following commands, all of which produce the errors shown:


The last error really has me
Why is it <code>test.InsideTest</code> a bad class file? It's named correctly and in the test directory???
------------------
Jane
[This message has been edited by Jane Griscti (edited October 12, 2000).]


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
This:
javac -classpath test TestPkg.java
will never work because you are telling it to look for the package in the test directory. You are telling it that you have your class in:
\java\jeg\examples\test\test
The other compile should work. The error message you are getting has nothing to do with not being able to find the package. What it is telling you is that there is no constructor matching the signature you are specifying! IOW, InsideTest has a constructor specified other than one that takes no arguments. If InsideTest.java looked like the following, you would get the error you are getting:

Once you specify any constructor that takes a parameter, the default constructor can no longer be used. You would have to add it explicitly for it to be available:

[This message has been edited by Thomas Paul (edited October 12, 2000).]


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Thanks Thomas but I didn't have any constructor in InsideTest. The compiler created the default noargs constructor <code>test.InsideTest()</code>.
I've tried using <code>new test.InsideTest()</code> inside TestPkg.java but I get the same <code>cannot resolve symbol</code> error.
Is there something else that needs to be set?
Thanks
------------------
Jane
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Well, I tried the same setup on my system at a work, an NT workstation and everything worked perfectly.
Used the following directory and file structure:
c:\java\save\test\PkgA.java - uses 'package test;'
c:\java\save\TestPkg.java - uses 'import test.*;'
The CLASSPATH enviroment variable was not set to anything. The files were compiled using JDK 1.3 from the c:\java\save directory using the following commands:
javac test\PkgA.java
javac TestPkg.java
Both files compiled correctly.
NOW ... why won't the same setup work on my machine at home under Win98???
Any suggestions as to what I can check on the operating system?
Thanks

------------------
Jane
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Found the solution thanks to Paul Anil.
For anyone else having similar problems with JDK1.3 under Win98 see this post http://www.javaranch.com/ubb/Forum24/HTML/004836.html
[ July 27, 2002: Message edited by: Marilyn de Queiroz ]
 
wood burning stoves
 
subject: Help with compiling packages