• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling Superclasses  RSS feed

 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually have a two parter on using JavaCompiler. I'm using Java 8, but only found a link to Java 7 JavaCompiler. (That's a note, not the problem as far as I know.)

I'll take the first which might just be answered by can or can't do that ... I've wanted to tell the compiler about my lowest, most sub- subclass and let it figure out that it needs to compile all the superclasses that are in fact, in the same package. But that never seems to work. I have to include a full list of source files.

My current options:



Construction of source file array:



Compile:



(Hint: Part 2 is about efficiency ... )
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Java 8, but only found a link to Java 7 JavaCompiler.

You mean the javadocs? Just change the "7" in the URL to "8", and there it is. Or, in a post here, you can use the built-in javadoc tag: javax.tools.JavaCompiler, which automatically links to the latest javadocs. It looks like "[javadoc]javax.tools.JavaCompiler[/javadoc]".
 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
I'm using Java 8, but only found a link to Java 7 JavaCompiler.

You mean the javadocs? Just change the "7" in the URL to "8", and there it is. Or, in a post here, you can use the built-in javadoc tag: javax.tools.JavaCompiler, which automatically links to the latest javadocs. It looks like "[javadoc]javax.tools.JavaCompiler[/javadoc]".


Nice feature.
 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please feel free to speculate. I'll be more than happy to test informed opinion. I'm thinking maybe JavaCompiler options etc. follow exactly the same rules and work the same way as using javac from the command line. You just put the stuff in Java code instead. That's why I originally posted this in Beginning Java. Long story on why I might be using more advanced (or less used) stuff like JavaCompiler in my code. (It's just Java, but it wouldn't surprise me so much if not many people have done this.) Doesn't matter. If you're "just" an expert on compiling some other way, feel free to chime in.

The question is whether javac will automatically compile super classes even if I don't include them on the command line. I do it all the time with classes I instantiate from within other classes. I compile whole systems by telling the compiler that I want to compile the object with the main() method. The only super classes I've used up till now have been Java classes (like Servlet) that already are compiled.
 
Roger F. Gay
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOLVED
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!