Bug 86795 - Impossible to use JDT in Java Application
Summary: Impossible to use JDT in Java Application
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-27 19:10 EST by julien CLA
Modified: 2005-02-28 12:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description julien CLA 2005-02-27 19:10:15 EST
In a Java Application with Eclipse 3.1M5a, when I call
    jdomFactory.createCompilationUnit(contents, "NAME");
I got the following exception: 

java.lang.ExceptionInInitializerError
	at org.eclipse.jdt.core.JavaCore.getOptions(JavaCore.java:2327)
	at 
org.eclipse.jdt.internal.core.jdom.SimpleDOMBuilder.createCompilationUnit
(SimpleDOMBuilder.java:66)
	at 
org.eclipse.jdt.internal.core.jdom.AbstractDOMBuilder.createCompilationUnit
(AbstractDOMBuilder.java:137)
	at org.eclipse.jdt.core.jdom.DOMFactory.createCompilationUnit
(DOMFactory.java:55)
        ....
Caused by: java.lang.NullPointerException
	at 
org.eclipse.jdt.internal.core.search.indexing.IndexManager.getJavaPluginWorking
Location(IndexManager.java:279)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.<init>
(IndexManager.java:49)
	at org.eclipse.jdt.internal.core.JavaModelManager.<init>
(JavaModelManager.java:521)
	at org.eclipse.jdt.internal.core.JavaModelManager.<clinit>
(JavaModelManager.java:499)
	... 18 more

It seems that JDT calls 
   IPath stateLocation = JavaCore.getPlugin().getStateLocation();

This same code works fine with Eclipse 3.0.1. 

julien
Comment 1 Olivier Thomann CLA 2005-02-28 03:21:50 EST
You need to run JDT/Core from a headless eclipse. Inside an Java application,
the JDT/Core plugin is not initialized.
Comment 2 Philipe Mulet CLA 2005-02-28 12:11:28 EST
JDT/Core is not meant to run outside Eclipse, it is a pure Eclipse component.