wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Java compiler acted strangely : please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java compiler acted strangely : please help" Watch "Java compiler acted strangely : please help" New topic
Author

Java compiler acted strangely : please help

gooi chin hin
Greenhorn

Joined: Dec 03, 2002
Posts: 9
I have 2 java class. ClassA and PiGbProperties. The strange thing is that when I compile ClassA, the java compiler automatically compiled PiGbProperties class too. Why is this happening? Below are the sample of the classes.


package my.com.batchapp.stmtrequest;
import com.mytemp.*;
public class ClassA extends BObject
{
...
...
private void connect () throws Exception
{
PiGbProperties piGbProperties = new PiGbProperties( );
piGbProperties.loadProperties("bankpbb",propPool);
dbAccessor = new PiGbDbAccessor(propPool);
}
}





package com.mytemp;
public class PiGbProperties extends BObject
{
public void loadProperties(String s, BAnythingPool banythingpool) throws Exception
{
...
...
}
}
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The connect() method here uses the PiGbProperties class, so the compiler needs to compile it in order to know what methods it contains.

Layne


Java API Documentation
The Java Tutorial
gooi chin hin
Greenhorn

Joined: Dec 03, 2002
Posts: 9
I don't think this is true as my java program also called some other class and they are not compiled.

Somebody told me that the problem is due to fact that the PiGbProperties class is inside a jar file. My class path contains both the location of the jar file and also the location of the PiGbProperties class file. When the compiler detected that the PiGbProperties.class (in the jar file) is older than the com.mytemp.PiGbProperties.java file, it will recompiled the PiGbProperties.class.

Is this true?
[ May 11, 2005: Message edited by: gooi chin hin ]
Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
Originally posted by gooi chin hin:
I don't think this is true as my java program also called some other class and they are not compiled.

Somebody told me that the problem is due to fact that the PiGbProperties class is inside a jar file. My class path contains both the location of the jar file and also the location of the PiGbProperties class file. When the compiler detected that the PiGbProperties.class (in the jar file) is older than the com.mytemp.PiGbProperties.java file, it will recompiled the PiGbProperties.class.

Is this true?

[ May 11, 2005: Message edited by: gooi chin hin ]


I think the original answer is correct.I tried to verify like this:

1) created a class A:
public class A{
public int i;
}

2)then created a classB using class A:
public class B{
public static void main(String args[]){
A a = new A();
a.i=3;
System.out.println("a.i-->"+a.i);
}
}

without compiling A tried to compile B..and lo and behold A also got compiled!
No jars here either.So I think the first answer is correct.

Thanks,
Sunetra.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to Java in General (Beginner.) C'mon.


[Jess in Action][AskingGoodQuestions]
gooi chin hin
Greenhorn

Joined: Dec 03, 2002
Posts: 9
The above example only work in the A.java has not been compiled before. For my case, it is different. Both are existing class. They are not new. Why do the java compiler recompiled my PiGbProperties?
gooi chin hin
Greenhorn

Joined: Dec 03, 2002
Posts: 9
Any idea?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java compiler acted strangely : please help