Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

compile java classes with circular dependency

Posted on 2009-07-14
5
Medium Priority
?
406 Views
Last Modified: 2012-05-07
I am using JavaCompiler from apache commons jci.

How are you suppose to take care of multi pass compilation especially when you have circular dependency between two java classes. A calls B, and B calls A. is there an order or particular way to call the compiler, so it will take care of the circular dependency?
0
Comment
Question by:bhomass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 600 total points
ID: 24853710
Trust me it works in only 2 passes:
1) to make up references,
2) to fulfill the referenced classes.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 24853732
Btw.: for almost any OS I recommend SUN's JDK 6.

Other remark: classes do not call each other, but call each others' methods.
That makes it easy to compile the lot in 2 runs.

A a = new A(); // Calls the constructor.

;JOOP!
0
 

Author Comment

by:bhomass
ID: 24853871
I don't see any api that will run 2 passes. if I use
compile(java.lang.String[] pResourcePaths, ResourceReader pReader, ResourceStore pStore, java.lang.ClassLoader pClassLoader)

will it automatically run twice?
0
 
LVL 2

Assisted Solution

by:ethnarch
ethnarch earned 400 total points
ID: 24855195
I am trying to figure out what your unique case is as there might be a better way to create these classes.  I would stay away from any classes that are that highly dependant.  Better practice would be to have in intermediary, but it's hard to tell without knowing what you are actually trying to accomplish.

Beyond that though why don't you just try compiling the code and then post the errors if any.  
0
 

Author Comment

by:bhomass
ID: 24855356
wonderful. by talking thru this with you guys, I walked into the answer.

indeed the api I posted does the job.

thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question