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

Help with compiling packages

 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic