Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » strange throwing of NullPointerExcepton
strange throwing of NullPointerExcepton [message #114190] Thu, 06 November 2003 00:01 Go to next message
Eclipse UserFriend
Originally posted by: dave_s42.hotmail.com

When I run the following code, I get a NullPointerException being thrown
from:

IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();

Can anyone provide any insight as to why this is happening, and how I can
fix it?

public class OurAst {
private IWorkbenchWindow window;
private IWorkbenchPage wbp;
private IEditorPart edt;
private IEditorInput ei;
private IWorkingCopyManager mgr;
private IWorkspace workspace;
private AST ourAST;

//default constructor
OurAst() {
try {
IWorkspace workspace = JavaPlugin.getWorkspace();
IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
...... (More code, but it's currently all commented out)
}
catch (Throwable e) {
e.printStackTrace();
}

};
Re: strange throwing of NullPointerExcepton [message #114216 is a reply to message #114190] Thu, 06 November 2003 04:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Dave S wrote:

>When I run the following code, I get a NullPointerException being thrown
>from:
>
>IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
>
>Can anyone provide any insight as to why this is happening, and how I can
>fix it?
>
>
Is your code parts of a plug-in and do you launch as Eclipse Run-time
Workbench? If not, then there's no workbench (window). And of course
providing a stack trace here would help to tell you more about the problem.

Dani

>public class OurAst {
> private IWorkbenchWindow window;
> private IWorkbenchPage wbp;
> private IEditorPart edt;
> private IEditorInput ei;
> private IWorkingCopyManager mgr;
> private IWorkspace workspace;
> private AST ourAST;
>
> //default constructor
> OurAst() {
> try {
> IWorkspace workspace = JavaPlugin.getWorkspace();
> IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
> ...... (More code, but it's currently all commented out)
> }
> catch (Throwable e) {
> e.printStackTrace();
> }
>
> };
>
>
>
Re: strange throwing of NullPointerExcepton [message #114315 is a reply to message #114190] Thu, 06 November 2003 09:44 Go to previous message
Eclipse UserFriend
This may also fail if you do not call it in the UI (main) thread.

Darin

"Dave S" <dave_s42@hotmail.com> wrote in message
news:bockiq$r6g$1@eclipse.org...
> When I run the following code, I get a NullPointerException being thrown
> from:
>
> IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
>
> Can anyone provide any insight as to why this is happening, and how I can
> fix it?
>
> public class OurAst {
> private IWorkbenchWindow window;
> private IWorkbenchPage wbp;
> private IEditorPart edt;
> private IEditorInput ei;
> private IWorkingCopyManager mgr;
> private IWorkspace workspace;
> private AST ourAST;
>
> //default constructor
> OurAst() {
> try {
> IWorkspace workspace = JavaPlugin.getWorkspace();
> IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
> ...... (More code, but it's currently all commented out)
> }
> catch (Throwable e) {
> e.printStackTrace();
> }
>
> };
>
Previous Topic:Adding method to ICompilationUnit
Next Topic:Can I automatically refresh my project contents? (xdoclet problem)
Goto Forum:
  


Current Time: Sat Jul 05 05:57:19 EDT 2025

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

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

Back to the top