Running a java class from within the plugin

Answered

Hello!

We're trying to execute a java compiled file (.class) from within the plugin.

We have no idea how to do so, checked for weeks and we're still stuck.

Please help us!

 

Thank you in advanced.

0
6 comments
Avatar
Permanently deleted user

This is a straight Java question.  There is nothing specific to plugins to deal with it.

You need to load the class through a class loader and call it through reflection.  See http://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html.  A quick search found this example: http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html.

0

Hello,

Thank you for your response.

We need to actually let them debug / run the class / project.. so we understand that class loader can't assist us.

In addition, do you know how we can load the run configurations from an existing project?

I mean, we need to run a specified project with specific run configurations but we failed in loading the run configurations

0
Avatar
Permanently deleted user

In that case, you need to go read and understand the community sources for how to debug, and probably should understand more about how Java processes and debuggers work in general.

Look for classes named "Debug.*Runner" (regex) in the community sources and they will get you started.  For java, you probably want JarApplicationDebugRunner.

0

Thank you very much,
I wanna ask another thing.. if I want to create a custome project creation for my plugin - I want to add external jars once someone creates the custome project.. how do I do that?

0

Override com.intellij.ide.util.projectWizard.ModuleBuilder#setupRootModel, passed in ModifiableRootModel has various methods of adding/modifying libraries, content roots etc. See also introduction http://www.jetbrains.org/intellij/sdk/docs/reference_guide/project_model/library.html

0

Please sign in to leave a comment.