• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wierd compile issues

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey folks, this is wierd...sorta:
I've got two .java files (Engine.java and Gui.java). Inside Gui.java I have a line that instantiates and instance of Engine and accesses one if Engine's methods.
Like this:
Engine e = new Engine();
e.setParams();
Now when I compile them separately, Engine compiles fine, but Gui dies when trying to instantiate Engine. HOWEVER....if I compile them with: javac *.java, they BOTH compile fine and all is well.
I've tried compiling Engine first and the Gui and the same deal, Engine works fine, Gui dies.
These files are both in the same directory.
Anyone got any ideas??

[This message has been edited by ryan headley (edited September 22, 2000).]
 
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ryan,
I would like to help you. Could you please be a little more specific about the statement:
"Now when I compile them separately, Engine compiles fine, but Gui dies when trying to instantiate Engine".
Does Gui die during compilation or while running? What specific error are you getting?
Thanks.
Stephanie
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it's been a few day ssince I have been home.
If I try to compile the file like so:
javac Engine.java
and then type:
javac Gui.java
Engine.java will compile fine, but Gui.java gives and error at the the line:
Engine e = new Engine();
I get two errors one for the first Engine and then one for Engine();
However compiling like this, javac *.java, they both compile fine and then I can run the program.
Any clues?
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out.
My classpath didn't contain anything to let the compiler know that the current directory was the place to find Engine.java.
I had to add a "." to my classpath. So now it looks like this in c:\autoexec.bat
set CLASSPATH=d:\javahome\blahblahblah;.;
the . means add the current directory to the classpath.
Still it's wierd that javac *.java worked. Maybe cause they were loaded into the compiler in the same instance.
hmmmmm
 
reply
    Bookmark Topic Watch Topic
  • New Topic