Adding Files to the Root of a Eclipse e4 rcp application - eclipse

In order to add some configuration files to an Eclipse e4 rcp application, I have followed the steps from greg-449 in this link:
The application is featured based, and in the feature project folder I have attached the file "test_config_file.txt"
At feature´s 'build.properties' file are the next lines:
bin.includes = feature.xml
root=file:test_config_file.txt
Basically it is what is stated at the above link.
When I run the product (via Run Configuration), the file is not copied to the folder where the Run Configuration locates the product.

The configuration in the feature is only used when you build / export a product.
When running the code using a Run Configuration you will have to put the files in the correct location manually. Alternatively your code could support a command line argument to specify the location of the file.

Related

Eclipse Plugin's plugin.xml file doesn't add a menu or export wizard specified in plugin.xml

I am trying to add a export action to the Eclipse File > Export dialog. I've tried adding it through plugin.xml (see below update about dropins vs plugins folder) and while it works in a Mars 2 (Eclipse Platform / RCP version 4.5.2) instance it does not work with version 4.6.2 where I'm intending to use the jar. Previously the plugin.xml did not work also for a menu item, however I was able to do that programmatically (but seemingly not add an export wizard programmatically).
Update 2: It seems it may have to do with the eclipse's configuration config.ini file or Equinox Transforms (see https://wiki.eclipse.org/Equinox_Transforms). I think it may be the later because the plugins run and you can add ui elements later (like the aforementioned menu) with programming, but not with the plugin.xml. Also the config.ini makes reference to the Equinox Transforms class.
Update 1: The plugin.xml not running seems to be related to something to do with the dropins folder.
Foo.jar provides some exports and was provided by the vendor through a P2 update site I believe and exists in a plugins folder.
When I rename Foo.jar to Foo.jar.old and re run the app (with -clean) the exports are removed (Good)
When I name it back to Foo.jar in the plugins folder it re adds the exports on startup (Good)
When I move Foo.jar to the dropins folder the plugin DOES LOAD (it's listed in Help > Installation Details > Plugins), however the export options specified in the plugin.xml are not populated. (Bad)
Is there a difference between the eclipse dropins folder and the eclipse plugins folder of a P2 update site?
I have since confirmed it was a Equinox Transform in use (it shows up in the plugin list). Upon searching for jar files mentioning transform one had the xlst files in the jar and unzipping them, editing them, rezipping them to a jar file and replacing the original fixed the problem (I did have to run eclipse.exe -clean otherwise it did cache the old one and seem not to work).
Also of note look at the config.ini it should make reference to Equinox Transforms.

Add configuration file for rcp binary

I created a .properties file in RCP application to specify the server address, so that I didn't need to modify the source code when the address is changed.
This works well when I run RCP from the .product file, but it didn't work when I exported the RCP to an executable app. I have included the conf.properties when exporting the RCP (add to build.properties of the feature).
I can't run the application by double clicking the .exe file. I have tried many methods to get the root path of rcp binary but every time it fails. So how to get this configuration file work in binary, or is there other way to do this?
Use
URL installURL = Platform.getInstallLocation().getURL();
to get a URL for the RCP installation directory.
An alternative is to set properties in the 'xxx.ini' file for your RCP ('console.ini') in your case.
You do this in the .product file editor by adding -Dpropery=value values to the 'VM Arguments' section on 'Launching' tab.
Note that during testing these values will not be used, in that case you can set properties in the 'Run Configuration' for the RCP.

How to change Eclipse RCP product exe properties

I am using Maven with Tycho plugin to materialize the Eclipse RCP product. What I need is when I right-click the product exe file and choose properties I need some relevant information onthe Details tab (File Description, Product Name, Product Version...).
Now I have found so far, that this could be achieved with .rc file with VERSIONINFO statement
(see Comment 10 at this bug). I also found in tycho-user mailing list that rc file CAN be included in Tycho build to achieve the desired behavior. Nontheless I was unable to find out where to put the rc file, or how to name it or where to set its location.
Thanks
You are misreading the bugzilla discussion, as that is only possible by self-compiling the eclipse launcher source (with a modified rc file).
However, there is an alternative: You can patch the launcher executable manually (using any kind of resource editor) and then put it into your product as root file. This works with tycho, I use that approach. The drawback is of course that this executable will not be updated, if you change branding details in the product definition file.
Alternatively to a root file you could also overwrite the launcher executable during an installation creation (outside of Eclipse). E.g. we create an NSIS installer around an RCP app and can also modify it there.

How the launcher of eclipse Plugin development project loads\handles the "plugin.xml" file?

I want to figure out how can I put a file in the root folder of the project and use it in run time, there it will be accessible.
The problem that I have by doing that (placing the file in the root folder)-is that by default it means:
It is not in the classpath of the project.
It is not copied to the bin (output) folder.
I can’t see how my modifications of the file will affect the run process.
As I know there is a similar mechanism in eclipse that does the same:
The Plugin development project has a file-"plugin.xml" in the root folder of the project.
When you make a change in the file without building the project or copying it to the bin folder the changes take place when you run it.
example:
add an extension point in ”plugin.xml” and hit “RUN”, it will take place immediately.
Does anybody have an idea how this mechanism works in eclipse?
Edit - for clarification :
I am interested in how the launcher of eclipse Plugin development project loads\handles the "plugin.xml" file.
I assume when you say you want to put a file in a "root folder of the project" you are refering to a plugin that you are developing and then in runtime you want to get access to that file. Please don't vote me down if I did not understand that question correctly but based on my understanding here are some steps to follow:
Open your MANIFEST.MF file /MANIFEST.MF, this will oepn a multipage editor.
Click on the build tab (third from right).
This is where you specify what resources in your plugin you want the builder to include in the plugin at runtime. You will notice that plugin.xml is already checked which is why extensions get updated each time.
Check the resource on this editor page for the resource you want to be able to load and access at runtime. Behind the scenes this is updating your build.xml which the internal builder uses to figure out what sources to build/add when building/exporting the plugin.
One you have done that this is how you can get access to that file, you get the Bundle for your plugin and call the getEntryMethod with the path to your file and then open in inputstream from there you can load it as a File or whatever you want. Code example below: Hope this helps - Duncan
Bundle myBundle = Platform.getBundle("com.mycompany.myplugin.id")
InputStream in = myBundle.getEntry("/myfile.txt").openStream();

How to create a Jar file in Netbeans

Well I have my source code that i have done using the IDE netbeans. Now I wanted to move this java application to a web application. For that I need to create a jar file from my source code, so that I could invoke it in ma jsp file.
I have not been able to find any option in netbeans or any other way to create a .jar file of this source code.
Could someone tell me how to do that.
Thanks
Create a Java archive (.jar) file using NetBeans as follows:
Right-click on the Project name
Select Properties
Click Packaging
Check Build JAR after Compiling
Check Compress JAR File
Click OK to accept changes
Right-click on a Project name
Select Build or Clean and Build
Clean and Build will first delete build artifacts (such as .class files), whereas Build will retain any existing .class files, creating new versions necessary. To elucidate, imagine a project with two classes, A and B.
When built the first time, the IDE creates A.class and B.class. Now you delete B.java but don't clear out B.class. Executing Build should leave B.class in the build directory, and bundle it into the JAR. Selecting Clean and Build will delete B.class. Since B.java was deleted, no longer will B.class be bundled.
The JAR file is built. To view it inside NetBeans:
Click the Files tab
Expand Project name >> dist
Ensure files aren't being excluded when building the JAR file.
Please do right click on the project and go to properties.
Then go to Build and Packaging.
You can see the JAR file location that is produced by defualt setting of netbean in the dist directory.
I also tried to make an executable jar file that I could run with the following command:
java -jar <jarfile>
After some searching I found the following link:
Packaging and Deploying Desktop Java Applications
I set the project's main class:
Right-click the project's node and choose Properties
Select the Run panel and enter the main class in the Main Class field
Click OK to close the Project Properties dialog box
Clean and build project
Then in the fodler dist the newly created jar should be executable with the command I mentioned above.
Now (2020) NetBeans 11 does it automatically with the "Build" command (right click on the project's name and choose "Build")