Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How can I add a Classpath Variable in code(What is the java code to call the IDE method 'Java Build Path - Libraries - Add Variable')
icon5.gif  How can I add a Classpath Variable in code [message #1468302] Mon, 10 November 2014 18:47 Go to next message
Mike Ciccarone is currently offline Mike CiccaroneFriend
Messages: 4
Registered: November 2014
Junior Member
Hi All,
I am trying to create a quick tool that will automatically generate a 'new workspace' from a list of project files that are contained within Version control. So far I have the tool to a point where it can find all project files and add them to a workspace, however I cannot figure out how to change the location of the new workspace.

The tool itself is setup as an Eclipse Plugin and it parses the command line arguments for various items. The argument I want to use is '-workspace <variable>' , however I do not know how to pass that into the project creation as '-data'

I'm using the following lines to add the projects to the workspace:
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
project.create(description, null);

The way it works now is that it creates a new workspace in the ..\Plugin-name directory of the last Workspace i have used.

Does anyone know how this can be done? (Without using the IDE switch/change workspace)

[Updated on: Mon, 10 November 2014 22:44]

Report message to a moderator

Re: Change the Workspace location [message #1468464 is a reply to message #1468302] Mon, 10 November 2014 21:47 Go to previous messageGo to next message
Mike Ciccarone is currently offline Mike CiccaroneFriend
Messages: 4
Registered: November 2014
Junior Member
A quick update:
Using the following code I have been able to get the Path Variable to show up in the IDE under 'Resources->Linked Resources [Path Variables]', however doing that doesn't seem to complete the process.

File testMe = new File("c:\valid\directory);
java.net.URI tmpUri = testMe.toURI();
org.eclipse.core.resources.IPathVariableManager ipvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
ipvm.setURIValue("MY_ROOT_VAR", tmpUri);

-To get it to work I have to open the IDE, select the project properties, then select 'Java Build Path', then press 'Add Variable...' here.
When I do this, all of the classes resolve successfully, so the question I still have is:

How do I add a Java Build Path 'Variable' programmatically within a Java plugin for eclipse?
Re: Change the Workspace location [message #1469682 is a reply to message #1468464] Tue, 11 November 2014 20:34 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1828
Registered: July 2009
Senior Member
Regarding Java classpath variables there are two possible entries:
- extension point org.eclipse.jdt.core.classpathVariableInitializer
- method org.eclipse.jdt.core.JavaCore.setClasspathVariables(String[], IPath[], IProgressMonitor)

But honestly, your description left me confused: is it that you want to switch to a new workspace location without "Switch Workspace"?
Is "Import > Team > Team Project Set" the functionality you are implementing?

Stephan
Previous Topic:JBOSS server give Deployment failed erorr
Next Topic:Setting a body in an http POST using apache httpClient
Goto Forum:
  


Current Time: Mon Nov 30 09:28:36 GMT 2020

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

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

Back to the top