Workspace is closed error - eclipse-rcp

I have created a EMF model and generated a model code for that. I have created one plugin project and i have created one class named as 'CommandTest' which is having "public static void main()" method which reads mymodel resource file.
Its working fine in eclipse 3.5.2. There is no issues am able to read the contents.
But same thing am running through command prompt, am getting error "Workspace is closed". I have included my plugin folder in my classpath.
I have used one statement resource.load(null). In this line am getting "IllegalStateException: Workspace is closed".
I want to run my project in commandline not in eclipse environment. I have searched this problem in internet, i can able to find some solutions but its all related to eclipse environment.
If anything am doing wrong in this following statement
====Code Snippet======
file = "C:\temp\mytemp.xml";
// Creating resource
XMLResource resource = (XMLResource) new MyModelResourceFactoryImpl().createResource(
URI.createURI(file.toURI().toString(), true));
resource.load(null);
=======================
Is it possible to run plugin project in commandline? if it is possible could any one guide me how to achieve this to avoid "workspace is closed" error?

Did you try to specify a workspace with the -data <workspace-path> command line switch? You could try as well to call Plugin.getStateLocation().

Related

provide wrong classpath for netbeans [duplicate]

I need to make a GUI Application for my class , so I want to make sure I can transfer a netbeans project using the GUI Builder (I know how to make it without it, but that's more time consuming and I think it would look neater without me guessing coordinates etc. and I was use to the netbeans GUI builder) from netbeans onto unix and compile it. So here's what I did I made a new JFrame form (using netbeans GUI Builder) called StartFrame.java and another called MenuFrame.java. (keep in mind that it ran with no errors in netbeans) StartFrame creates a new instance of MenuFrame and opens it on it's first run. So I transferred all of it onto the unix system. So at first I tried compiling it, but of course it got errors, saying that org.jdesktop... isn't found.
Okay so I've already searched stackoverflow and the web for this. So I ended up getting the swing-layout-1.0.4.jar from the libraries in netbeans.
I'm kind of new at compiling from command line, but I put them all in the same folder, and while I was in that directory.
I did
javac StartFrame.java -cp swing-layout-1.0.4.jar
and I got the error that NoClassDefFoundException: MenuFrame even though it is in the same folder. So then I tried
javac StartFrame.java MenuFrame.java -cp swing-layout-1.0.4.jar
and it compiled fine with no errors. So then It created 6 files StartFrame.class StartFrame$1.class StartFrame$2.class StartFrame$3.class StartFrame$4.class MenuFrame.class
I tried running it with
java -cp swing-layout-1.0.4.jar StartFrame
and it had a NoClassDefFoundException: StartFrame. I searched the web for fixes for this and stack overflow and found similar (not exact though) problems like this, but none of those fixed it.
The file dist/README.TXT will tell you how to proceed. Type ant -p at the command line to see that available commands: ant run is usually good.
Addendum:
The machine doesn't have ant installed
That would be unusual, so you should certainly verify it. You may need to add the current directory to the path, e.g.
java -cp .:swing-layout-1.0.4.jar StartFrame

Problem while trying to execute ant file in java

I'm trying to compile a service using a java ant file as appears below:
and my buid-jar.xml looks like this:
the problem i have is that eclipse is not recognizing the enviroment variables and it takes the names literally causing an error on building time:
Both, paths and ant files does exists in these routes in my user folder, but i don't know why this error is happening. I'm using jdk 1.8.0_45.
Any idea? Sorry i had to attach screenshots instead code, but the proxy of the company network that i work for doesn't allow me to navigate on stackoverflow.

"Errors exist in the active configuration..." Eclipse Dialog when Debugging

An "Errors exist in the active configuration of project X. Proceed with launch?" dialog appears while debugging code in Eclipse. Hitting the "Proceed" button results in successful debugging. There are no apparent errors with the launch configuration. A similar Run Configuration does not generate the error.
This is caused by an invalid path somewhere in your Eclipse project settings. There are a couple common sources for this kind of error.
You're working on a shared (version controlled, copied, etc) project where someone has hardcoded a path that doesn't exist on your machine, or uses an environment variable that you've not set.
Sometimes, you can find the offending path by looking at the full list of Error messages. If not, look in your project file.
The Discovery Options in your project properties has 'Automate discovery of paths and symbols' enabled - but the process is generating an error.
If you're using a version of Eclipse that warns you this option is deprecated, uncheck the option to disable it and fix any includes in 'Preprocessor Include Paths' instead. If not. . .try it anyway.
Depending on your path changes, restart Eclipse and try again.
It starts the executable that was built last before you broke the build. That executable will be older then your source files. The reason you were able to debug is because your line numbers did not change for the code you've debugged - e.g. you may try break in main then introduce a compilation error and move main a couple lines below - the debug will highlight the wrong lines when it stops.

"Could not parse configuration file..." when I add EF6 to a solution

I get an error when I add EF6 to a solution. I think it also happens when I update the model from the database. The error shows up in the Output window right after I add EF: "Could not parse the configuration file. The error message is: 'Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))' Try editing the file manually and then saving it."
The "error" doesn't seem to have any influence on the compiling or running of the application (or the function of EF). However, an error like this is always disturbing when it's with the technology that is supposed to be the linchpin of your data management strategy.
I believe that I have discovered the problem. I can repro it on my development machine and a couple of other dev machines.
I am using VS 2013. The solution that I was using included a second project, a setup/deployment project, InstallShield Limited Edition Project. If I remove that project, the errors go away.
If I create a new project, add EF via Nuget, add an EF model to the solution and then add this setup project I can repro the error. If you try it yourself, just remember you need to open VS and the solution, open the model in the designer, click anywhere in the whitespace of the design surface, the error should pop up in the Output. The details are up there in an earlier post.

Convenient way to run eclipse plugin

I have recently started developing an Eclipse plugin (which is basic stuff for now) and I am struggling with "default" way to run Eclipse plugin ("Run as Eclipse application").
The Eclipse is starting another instance with my plugin already installed in it (this is default behaviour).
The problem is that when I want to re-run my plugin project and I press "run" button again (or Ctrl + F11) (and the another Eclipse instance still running) I get following message:
"Could not launch the application because the associated workspace is currently in use by another Eclipse application".
The error makes sense, and when I close "testing" Eclipse instance I am able to run my plugin again.
The question is - "is it normal routine for plugin development?". Maybe I am missing something, e.g. special arguments for Eclipse?
This seems all pretty normal. The error message is since the run configuration is specifing a workspace and when you start a second instance using the same workspace it is locked and considered in use.
What I usually do when testing a plugin is to create a run configuration (click "Run...") where I disable all the plugins I wont need when testing. This makes sure that the test starts up a couple of seconds quicker. Make sure you save that run configuration as a *.launch file aswell, that makes it quicker to test the next time. Or it can be used to share the configuration.
There's a lot you can configure in the run configuration, such as eclipse arguments, vm argument, if you want environment variables set, etc. So be sure to experiment a little.
In your run configuration. Main tab->Workspace Data ->Location text box add this:
${workspace_loc}/../runtime-EclipseApplication${current_date:yyyyMMdd_HHmmss}
Note the suffix ${current_date:yyyyMMdd_HHmmss} by this every time you launch your application new workspace will be created. So you will not get any error message saying workspace is locked.
But be careful as the folder .metadata will be different for different instances as their work-spaces are different. Thus preferences stored/retrieved by different instances are NOT in sync.
You are probably missing one important point: Eclipse supports the Java hot code replacement. Therefore in many cases you can modify your Java code while your application Eclipse instance is running, save the code and continue without restarting.
If hot code replacement is not possible, Eclipse will tell you, so you always know whether the editing changes are applied to the running instance.
This works best with more recent versions of the JVM, so consider upgrading to the latest Java 7 version, even if you write code to be compliant with Java 1.5 or 6.