How to get java command-line

Hi,

In my pugin i'm trying to get java command line that starts application from the current run configuration.
I use this code:

public static JavaParameters getJavaParameters( final DataContext dataContext
, final RunConfiguration runcfg )
{
return ApplicationManager.getApplication().runReadAction(new Computable]]>() {
public JavaParameters compute() {
JavaProgramRunner runner = ExecutionRegistry.getInstance().getDefaultRunner();
JavaParameters javaParameters;
try {
JavaCommandLineState state = (JavaCommandLineState) runcfg.getState( dataContext
, runner.getInfo()
, null, null );
javaParameters = state.getJavaParameters();
} catch (ExecutionException exeption) {
// exeption.printStackTrace();
javaParameters = null;
}
return javaParameters;
}
});

but i get the following exception:
java.lang.NullPointerException
at com.intellij.execution.application.ApplicationConfiguration$MyJavaCommandLineState.createJavaParameters(ApplicationConfiguration.java:27)
at com.intellij.execution.configurations.JavaCommandLineState.getJavaParameters(JavaCommandLineState.java:30)
at com.excelsior.jetplugin.idea.JetPluginUtils$1.compute(JetPluginUtils.java:93)
at com.excelsior.jetplugin.idea.JetPluginUtils$1.compute(JetPluginUtils.java:85)
at com.intellij.openapi.application.impl.ApplicationImpl$12.run(ApplicationImpl.java:3)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:210)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:136)
at com.excelsior.jetplugin.idea.JetPluginUtils.getJavaParameters(JetPluginUtils.java:85)
at com.excelsior.jetplugin.idea.actions.JetActionManager.createJetControlPanelProject(JetActionManager.java:89)

can anybody advice me?

2 comments

Did you find the issue already? (have the same problem)

0

now we use
-


runcfg.getState( dataContext, runner.getInfo()
, new RunnerSettings]]>(null, null)
, null );
-


instead of
-


runcfg.getState( dataContext
, runner.getInfo()
, null, null );
-


to get JavaCommandLineState object.

in OpenAPI for IDEA 6 RunnerSettings object wasn't used in getJavaParameters() method, but for IDEA 7 this method uses RunnerSettings. And i don't find any examples how should i get this object.

this workaround works fine in my case

0

Please sign in to leave a comment.