Missing Resource Exception while creating a command line application


I am creating Idea Application using open API. I am trying to open a existing Idea project as a command line application.
I am using the following code:

ApplicationManagerEx.createApplication(true, true, true, true, "Sample", null);
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
Project myProject = ProjectUtil.openOrImport("C:/samples", null, false);

This code is throwing the following exception:

Caused by: java.util.MissingResourceException: Can't find bundle for base name misc.registry, locale en_US
 at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
 at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
 at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
 at com.intellij.openapi.util.registry.Registry.getBundle(Registry.java:97)
 at com.intellij.openapi.util.registry.RegistryValue.getBundleValue(RegistryValue.java:148)
 at com.intellij.openapi.util.registry.RegistryValue._get(RegistryValue.java:133)
 at com.intellij.openapi.util.registry.RegistryValue.get(RegistryValue.java:114)
 at com.intellij.openapi.util.registry.RegistryValue.asInteger(RegistryValue.java:70)
 at com.intellij.openapi.util.registry.Registry.intValue(Registry.java:69)
 at com.intellij.openapi.application.impl.ApplicationImpl.<clinit>(ApplicationImpl.java:126)
 ... 3 more

I checked for misc.registry in idea community edition project. I can;t find a file with this name.
Am I missing something here?

Once I open the project, I like to query for type search/usages/ hierarchy etc using open API. Hope I am in right direction :)


Comment actions Permalink

This is not a correct way to create an IntelliJ IDEA application. If you want to write a command-line tool that uses the IntelliJ IDEA API, you need to either implement the ApplicationStarter extension point (if you want to distribute your tool as a plugin for IntelliJ IDEA) or to use the JavaCoreApplicationEnvironment and JavaCoreProjectEnvironment classes to set up the environment for you (if you plan to distribute it as a standalone tool).

Comment actions Permalink

Looking at the APIs of JavaCoreApplicationEnvironment and JavaCoreProjectEnvironment, I see that we can manage java classes,jars etc with these classes.
I want to open an existing Idea project (that was created using Idea, with .idea dir ), and access the classes, inheritance, methods in the project, without launching the Idea GUI. (in a headless environment). Please point me to an  example or OpenAPI class to start with?

Comment actions Permalink

In that case you should use the ApplicationStarter extension point.


Please sign in to leave a comment.