Loading co-dependent groovy classes in Java -


I am trying to find two co-dependent gruby scripts in Java on runtime. If I have two groovy scripts:

A..groovy

  import b square A {a () {bb = new b ()}}        > I want to load them as Java classes, but when I run: 

  classloadloader root = getClass (). GetClassLoader (); GroovyClassLoader Loader = New GroovyClassLoader (Original); Loader.parseClass (new file ("Agrowvy");  

I get an error:

  org.codehaus.groovy.control.MultipleCompilationErrorsException: startup fail: A.groovy: 1: solve square b Unable to @ line1, column 1. Import B  

I certainly understand the cause of this error, but does this section have any way of loading over runtime despite co-dependency is? Thanks!

GroovyClassLoader must be enabled to find B Jarovi on square path. It usually means that you change the classpath to include the root of the scripts. Since there is no package for scripts and since you use the new file ("AguVV"), I believe that this is the current directory.

If you do not want to change it, the application's pathway, you can also call the addURL to add the scripts to the path.

One more thing to mention .... parseClass will always create a new parsed class. Instead of avoiding the compilation of the file several times, you can try a standard load class call but it is important that you work only after setting a look for GroovyClassLoader, because using the load class, the GroovyClassLoader is also using the same By the way, A.groovy has to be seen, on which it is called B.groovy


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -