Eclipse Juno: Unable to read model extension - eclipse

After exporting the product, when i try to run the application i do not see any view in my application.i got the reason, this is because of error "Unable to read model extension"

Does your product work fine when launched from within the Eclipse IDE? Only the exported product generates the error? Then check if the exported product indeed includes all the required files. For example, does it include the plugin.xml, Application.e4xmi, ...?
When launched from within the IDE, all source code files are available to the running product. When exported, however, only files specifically listed in the build.properties file of each plugin will part of the exported product. If for example the model files (*.e4xmi) are not listed in the build.properties file, your exported product will not be able to load the model.

Related

When debugging my Eclipse plugin, the repository version of the Java file is chosen over my local version

I'm in the early stages of creating a new Eclipse plug-in in Eclipse 2019-06. I created the plug-in using the "Hello World" wizard option and created a debug configuration that successfully launches a secondary workbench for testing. I can click on my new menu option and step into my new code.
I want to use a modified version of org.eclipse.jdt.junit.wizards.NewTestCaseWizardPageOne, so I added the package to my project and edited NewTestCaseWizardPageOne. However, when I try to debug, the debugger asks for a source location. It seems to want to load the file from the local repository (.p2/pool/plugins/org.eclipse.jdt.junit_3.11.400.v20190510-0840.jar), rather than my edited version. Why is that?
There must be some kind of classpath problem, but don't versions of files in the project have precedence over those in the dependent plugins? I've looked at a number of similar questions (1, 2) and other sources, but I haven't yet found the answer. Please help.
Following Alexander Federov's suggestion, I converted my plugin into a fragment. This was fairly easy to do following the advice from this StackOverflow page. The main changes were:
Renamed plugin.xml to fragment.xml and changed the top level xml
element from plugin to fragment.
Added a Fragment-Host entry to MANIFEST.MF
The key advantage that this provided is discussed in an Eclipse Wiki
page:
... a fragment appears much the
same as a normal plug-in. A fragment can specify libraries,
extensions, and other files. When it is loaded by the platform loader,
a fragment is logically, but not physically, merged into the host
plug-in. The end result is exactly the same as if the fragment's
manifest were copied into the plug-in manifest, and all the files in
the fragment directory appear as if they were located in the plug-in's
install directory. Thus, a runtime library supplied by a fragment
appears on the classpath of its host plug-in. In fact, a Java class in
a fragment can be in the same package as a class in the host and will
even have access to package-visible methods on the host's classes.
The last part having to do with access to package-visible methods was what I needed. Thanks, Alexander!

How to synchronize run configuration with product configuration in Eclipse?

I am trying to run an Eclipse product that is configured to use features.
The features added by me are:
org.eclipse.e4.rcp
org.eclipse.emf.ecore
org.eclipse.emf.common
The product will run after using the run configuration->add required plugins button (the product plugin itself is missing example: if the product plugin is called com.company.product I will get a validation error that com.company.product is missing).
If I am using "Launch an Eclipse application" I will get the error "No application id found". This is also obviously reflected in the exported product.
I tried to add the product plugin as dependency but I can't find it. Still the "add required plugins" can add it.
Why is the product plugin itself required and how to add it in the configuration such that the exported product can run ?
I' not sure I really understand the question, but if you are using a feature based product you need to write a feature containing all of your plugins including the one that defines the product using the org.eclipse.core.runtime.product extension point.
Every plugin that you want to be included in the RCP must be listed in a feature and all the features must be listed in the product file.
I don't know of anything that will synchronize the Run Configuration with the product file.

Bundle eclipse.ini with product in deployable feature?

I am exporting a deployable feature which bundles a product plugin. Within this product plugin, I have created a customized welcome page and a splashscreen. Now I want that after installation of the exported deployable feature, the eclipse.ini file will be changed in order to pass my own product plugin to the argument -product and -showsplash. Currently, users need to make these changes manually after installation of the feature. Is there a better way, for example to bundle the modified eclipse.ini with the product?
In your feature's build.properties file, you can have it include arbitrary files with a line like this:
root.win32.win32.x86=absolute:file:eclipse.ini
Information on what can be included in the build.properties file can be found here.
Eclipse ini is normally created during build or installation. The content can be given inside the ProductConfiguration Editor - Launching. You can specify your parameters there and they will be entered into your build generated p2 product. When the product is installed the parameter will be added to the eclipse.ini file.

How to initialize project when it is imported

I have an eclipse plugin and a custom project type. When the project is created through the wizard i can do as much setup code as i want. While using the plugin an .xml file is created containing plugin specific information about some resources inside the project.
Now when the project is checked into a versioning system the xml file is included. When someone checks out the project into eclipse again i would have to read the .xml file and apply the information to the resources again.
Is there a place where i can put code that is executed when a project of my custom project nature is beeing imported from somewhere else ?
You could use an IResourceChangeListener to listen for resource changes.
Your listener should get an IResourceDelta for the project with the 'kind' flag set to IResourceDelta.ADDED.

.jcp equivalent for eclipse?

for one of my labs I have in my CS2 class at school, JCreator is installed on the school's computers with a 4.x version, I'm more of an eclipse person myself, I even use it at school in place of JCreator, but the file extension .jcp from what I know is a JCreator related file extension. What can I do to make a folder of files compatible with eclipse, which I use at home as well?
Eclipse identifies its projects by using two files namely .classpath and .project. As long as you can export those along with the project files and structure, you should be able to import a project into another eclipse instance.
I am not sure JCreator can create those files for you but I am sure that every eclipse project generates these files.
You can keep the JCreator specific files in the project folder(s), eclipse will ignore all the files that it cannot process/understand. The problem will be how to keep the libraries you are using in sync in both IDE environments as you edit your project.
You might want to re-factor that out to a build management tool like ant/buildr/maven