Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » how to get an open file's project name inside Eclipse
how to get an open file's project name inside Eclipse [message #1817994] Wed, 04 December 2019 04:50 Go to next message
Ming Cheng is currently offline Ming ChengFriend
Messages: 18
Registered: December 2019
Junior Member
Assume within Eclipse workspace, I have 2 projects and I opened a file belonging to 1 project. How to get this file's project name using java code? And if possible, how to get this project's home folder?
Re: how to get an open file's project name inside Eclipse [message #1818006 is a reply to message #1817994] Wed, 04 December 2019 07:01 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31781
Registered: July 2009
Senior Member
So you opened an org.eclipse.core.resources.IFile and you can call org.eclipse.core.resources.IResource.getProject() on that to get the IProject and for that you can call org.eclipse.core.resources.IResource.getName(). On any of these, you can call org.eclipse.core.resources.IResource.getLocationURI() to get the location.

You should just experiment with and read about the APIs that are available...

Ed Merks
Professional Support:
Previous Topic:copy-paste now quotes the copied text . How to stop that?
Next Topic:why PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null
Goto Forum:

Current Time: Tue Mar 09 05:22:26 GMT 2021

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

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

Back to the top