• 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

Compiling with Java 1.4

 
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am seeing an interesting problem with the 1.4 compiler. I had a batch script that I used to compile a program under 1.3. It simply compiled one source file at a time (starting with the dependent classes), copied them into their appropiate directories (packages) and then deleted the class files from the current directory. This script no longer works with 1.4. I get tons of errors saying it can find this and that class. After playing around for a while, I discovered that I could pass in multiple source files to the compiler. If I do this, it works fine. Then after everything is compiled, I copy the classes into their package directories. Does anyone know why the first batch script no longer works? I did not know I could pass in multiple files to the compiler. Was this also in 1.3? Is there a limit to how many source files can be compiled at once? I appreciate anyone who has an insight to this!

Thanks,
Barry
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's always been possible to pass multiple sources into the compiler at one time.
I can think of two potential problems:
1) Your script took advantage of an environment setting that doesn't apply to the new release (i.e., CLASSPATH, or a supplementary JAR file that the 1.4 install doesn't see).
2) Your JDK has a bug, or worse, a "negative correction" that invalidates what your script does. I define a negative correction as something productive the compiler does that isn't legal, according to the specification. When it's "fixed," stuff that took advantage of the oversight breaks.
Possibly by passing in multiple sources, you resolve a CLASSPATH issue that occurs when the compiler can't see everything at once.
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it's definitely not the first scenario, because there are not dependent jars. It seems your second idea is the case. As far as the CLASSPATH issue goes, I don't understand how this would be a problem. Here is my situation:
I have a class with package name com.test.MyClass
My script compiles that class and copies the class file to the com\test directory. Then the script compiles a class with no package name. It just sits at the root. ( I have heard this is bad practice. Is it? ) Anyway, the compiler is not able to find the com.test.MyClass class and complains on the import, thus causing the whole thing to fail. This is just an example. The real application has many packages, and the compiler complains about all of them. The script worked before with 1.3 and there have been no changes except switching to 1.4. So, maybe someone can tell me was I compiling improperly before and it worked anyway or is there a bug in 1.4???
Thanks,
Barry
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not try Ant instead of writing scripts?
[ March 20, 2002: Message edited by: Thomas Paul ]
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may or may not be one of your problems, but under jdk1.4, they fixed a "bug" in the compiler that allowed you to import classes without fully qualifying their names with their package. Of course, this is only an issue with classes in the default package.
The short story is, classes in the default package are not importable any more. The default package really only exists for "hello world" type applications anyway.
But since you mentioned something about having classes that aren't in a package, this could be an issue.
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I did read about not being able to import the default package in the release notes. But in my case, I am trying to import classes that are in a package into the default class, instead of the other way around. It makes no sense why it doesn't work.
As to using Ant. Yes, this looks interesting. I have heard about it before but just haven't got around to trying it. Do you find it fairly easy to use.
Thanks,
Barry
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is a "default class?"
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what a "default class" is. What I meant to say is that I was importing classes that were in a package to a class that was not in a package.

Barry
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic