Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » NullPointerException at JavaCore.getOptions(JavaCore.java:1248)
NullPointerException at JavaCore.getOptions(JavaCore.java:1248) [message #54015] Wed, 11 June 2003 01:05 Go to next message
Eclipse UserFriend
Originally posted by: dbexternal.comcast.net

Just started playing with the JDT Core, writing a real simple program to
parse an AST, and I'm getting a NullPointerException at
JavaCore.getOptions(JavaCore.java:1248).

I must be doing something wrong. Any help would be greatly appreciated....

My code goes down on the AST.parseCompilationUnit() operation:
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: TestAST <JavaFile.java>");
System.exit(1);
}

String contents;

if ((contents = getSource(args[0])) == null)
System.exit(1);

CompilationUnit cu = AST.parseCompilationUnit(
contents.toCharArray() );

Thanks, Dennis
Re: NullPointerException at JavaCore.getOptions(JavaCore.java:1248) [message #54248 is a reply to message #54015] Wed, 11 June 2003 09:00 Go to previous messageGo to next message
Jerome Lanneluc is currently offline Jerome LannelucFriend
Messages: 572
Registered: July 2009
Senior Member
Dennis,

Functionalities in JDT/Core can work only if the Platform is running. You
cannot invoke JDT/Core from a main(String[]) method. You will need to write
a plugin that requires org.eclipse.jdt.core.

Jerome

"Dennis" <dbexternal@comcast.net> wrote in message
news:bc5v9h$l6u$1@rogue.oti.com...
> Just started playing with the JDT Core, writing a real simple program to
> parse an AST, and I'm getting a NullPointerException at
> JavaCore.getOptions(JavaCore.java:1248).
>
> I must be doing something wrong. Any help would be greatly
appreciated....
>
> My code goes down on the AST.parseCompilationUnit() operation:
> public static void main(String[] args) {
> if (args.length < 1) {
> System.out.println("Usage: TestAST <JavaFile.java>");
> System.exit(1);
> }
>
> String contents;
>
> if ((contents = getSource(args[0])) == null)
> System.exit(1);
>
> CompilationUnit cu = AST.parseCompilationUnit(
> contents.toCharArray() );
>
> Thanks, Dennis
>
Re: NullPointerException at JavaCore.getOptions(JavaCore.java:1248) [message #54274 is a reply to message #54248] Wed, 11 June 2003 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dbexternal.comcast.net

Thanks Jerome, I heading down that path now. Having read the PlugIn
JavaDoc, I'm assuming I just need to extend PlugIn, but I wasn't sure how
to gain access to the plugin from a main(String[]) method?

Thanks, Dennis
Jerome Lanneluc wrote:

> Dennis,

> Functionalities in JDT/Core can work only if the Platform is running. You
> cannot invoke JDT/Core from a main(String[]) method. You will need to write
> a plugin that requires org.eclipse.jdt.core.

> Jerome

> "Dennis" <dbexternal@comcast.net> wrote in message
> news:bc5v9h$l6u$1@rogue.oti.com...
> > Just started playing with the JDT Core, writing a real simple program to
> > parse an AST, and I'm getting a NullPointerException at
> > JavaCore.getOptions(JavaCore.java:1248).
> >
> > I must be doing something wrong. Any help would be greatly
> appreciated....
> >
> > My code goes down on the AST.parseCompilationUnit() operation:
> > public static void main(String[] args) {
> > if (args.length < 1) {
> > System.out.println("Usage: TestAST <JavaFile.java>");
> > System.exit(1);
> > }
> >
> > String contents;
> >
> > if ((contents = getSource(args[0])) == null)
> > System.exit(1);
> >
> > CompilationUnit cu = AST.parseCompilationUnit(
> > contents.toCharArray() );
> >
> > Thanks, Dennis
> >
Re: NullPointerException at JavaCore.getOptions(JavaCore.java:1248) [message #54512 is a reply to message #54274] Wed, 11 June 2003 13:20 Go to previous message
Jerome Lanneluc is currently offline Jerome LannelucFriend
Messages: 572
Registered: July 2009
Senior Member
Just to clarify: a plugin cannot be invoked from a main(String[]) method.
You need to use the Platform launcher to launch the Eclipse Platform (see
org.eclipse.core.launcher.Main in startup.jar).

For further questions about plugin and the Eclipse Platform, you should ask
on the eclipse.platform newsgroup.

Jerome

"Dennis" <dbexternal@comcast.net> wrote in message
news:bc6rh8$8mb$1@rogue.oti.com...
> Thanks Jerome, I heading down that path now. Having read the PlugIn
> JavaDoc, I'm assuming I just need to extend PlugIn, but I wasn't sure how
> to gain access to the plugin from a main(String[]) method?
>
> Thanks, Dennis
> Jerome Lanneluc wrote:
>
> > Dennis,
>
> > Functionalities in JDT/Core can work only if the Platform is running.
You
> > cannot invoke JDT/Core from a main(String[]) method. You will need to
write
> > a plugin that requires org.eclipse.jdt.core.
>
> > Jerome
>
> > "Dennis" <dbexternal@comcast.net> wrote in message
> > news:bc5v9h$l6u$1@rogue.oti.com...
> > > Just started playing with the JDT Core, writing a real simple program
to
> > > parse an AST, and I'm getting a NullPointerException at
> > > JavaCore.getOptions(JavaCore.java:1248).
> > >
> > > I must be doing something wrong. Any help would be greatly
> > appreciated....
> > >
> > > My code goes down on the AST.parseCompilationUnit() operation:
> > > public static void main(String[] args) {
> > > if (args.length < 1) {
> > > System.out.println("Usage: TestAST <JavaFile.java>");
> > > System.exit(1);
> > > }
> > >
> > > String contents;
> > >
> > > if ((contents = getSource(args[0])) == null)
> > > System.exit(1);
> > >
> > > CompilationUnit cu = AST.parseCompilationUnit(
> > > contents.toCharArray() );
> > >
> > > Thanks, Dennis
> > >
>
>
>
>
>
Previous Topic:Q: Can JDT API be used headless?
Next Topic:Where can I find headless jdt.core sample code?
Goto Forum:
  


Current Time: Fri Nov 08 23:23:56 GMT 2024

Powered by FUDForum. Page generated in 0.03080 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top