Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to get the project name in workspace in eclipse?(How to get the project name in workspace in eclipse?)
icon1.gif  How to get the project name in workspace in eclipse? [message #644976] Wed, 15 December 2010 02:46 Go to next message
hansen  is currently offline hansen Friend
Messages: 13
Registered: December 2010
Junior Member
Hi,
I want to get the file in the project in the workspace when eclipse is run time.
But I don't know how to get?

Thanks in advance!
Re: How to get the project name in workspace in eclipse? [message #644986 is a reply to message #644976] Wed, 15 December 2010 05:49 Go to previous messageGo to next message
hansen  is currently offline hansen Friend
Messages: 13
Registered: December 2010
Junior Member
Hi,
It is a plug-in project.
I open two eclipse environments.
one is main environment.
the other is run time eclipse environment.
In run time eclipse environment, I have a project.
In the main environment, I want to access the file in the project in run time eclipse environment.
How to do it?

Thanks!
Re: How to get the project name in workspace in eclipse? [message #644987 is a reply to message #644976] Wed, 15 December 2010 06:10 Go to previous messageGo to next message
hansen  is currently offline hansen Friend
Messages: 13
Registered: December 2010
Junior Member
Hi,
It is a plug-in project.
I open two eclipse environments.
one is main environment.
the other is run time eclipse environment.
In run time eclipse environment, I have a project.
In the main environment, I want to access the file in the project in run time eclipse environment.
How to do it?

Thanks!
Re: How to get the project name in workspace in eclipse? [message #645050 is a reply to message #644987] Wed, 15 December 2010 11:41 Go to previous messageGo to next message
Arlindo is currently offline ArlindoFriend
Messages: 33
Registered: August 2009
Member
Use the following code in your plug-in project:

Quote:
// Get the root of the workspace
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();

// Get the project (in the workspace) we want
IProject project = root.getProject( projectName);


For more information, these two tutorials are just what you need:

Eclipse Corner Articles: Abstract Syntax Tree
Eclipse JDT - Abstract Syntax Tree (AST) and the Java Model - Tutorial

[Updated on: Wed, 15 December 2010 11:42]

Report message to a moderator

Re: How to get the project name in workspace in eclipse? [message #645219 is a reply to message #645050] Thu, 16 December 2010 01:39 Go to previous messageGo to next message
hansen  is currently offline hansen Friend
Messages: 13
Registered: December 2010
Junior Member
Thanks!
what you say is correct!
But I want to get the file in the project when the project is in run status in eclipse!
So how to get the project object in run status?
Re: How to get the project name in workspace in eclipse? [message #645394 is a reply to message #645219] Fri, 17 December 2010 01:46 Go to previous messageGo to next message
hansen  is currently offline hansen Friend
Messages: 13
Registered: December 2010
Junior Member
The problem is resolved! Laughing
Re: How to get the project name in workspace in eclipse? [message #645554 is a reply to message #645394] Fri, 17 December 2010 21:42 Go to previous message
Arlindo is currently offline ArlindoFriend
Messages: 33
Registered: August 2009
Member
The plugin you program, will only be integrated in the new "Run" instance of Eclipse, so, you will actually be accessing the projects in the "Run" instance.
Previous Topic:Getting an error when trying to create a java project programmatically
Next Topic:What is inner class emulation?
Goto Forum:
  


Current Time: Fri Apr 26 21:23:17 GMT 2024

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

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

Back to the top