Will OSGI equinox install copy jar to its own folder - osgi

I an curious of what installing a bundle into Equinox is supposed to do:
Will it actually copy my jar to somewhere inside Equinox folder so that when I delete my jar, it will not affect the installed bundle?

When a bundle is installed (in any OSGi framework), it is persisted in the bundle cache. So yes, you can delete your JAR after installing it. The framework will remember what bundles were installed (and started) across restarts of the framework.

Related

Referencing RocksDB DLL in SBT

I am using RocksDB in a scala project with SBT.
For windows I understand that I need to infor SBT about the win64 DLL which is inside the jar file, but am still not getting this right.
I have tried what us written here but with no luck
How to resolve a non-jar (dll/jnilib) library dependencies in sbt?
How do I use RocksDB in a windows Java project?
You don't need to explicitly tell SBT about the Native Library (DLL on Windows) and the Rocks Jar file includes the Native Library and the startup code of RocksDB knows how to load that from the Jar.
Just include the RocksDB jar dependency (which includes the DLL) in your SBT build file as you would any other Java library.

How to uninstall old OSGI bundle version upon installation of a new version?

I am using the CQ Blueprints maven archetype for Adobe CQ to deploy OSGi bundles into CQ5.6.1. This archetype uses the Maven Sling Plugin to deploy the bundles by copying them into an install directory of my content repository.
I am changing the version numbers of my bundles upon every build using the maven versions plugin. Therefore, upon each deployment, a bundle jar with a new filename is installed, like commons-services-1.0.30.jar. My problem is, currently the older bundle versions, like commons-services-1.0.29.jar, are not removed upon installation of a newer version.
I would like to avoid old bundle versions piling up in my install folders. Therefore my question is: What is the best way to uninstall/delete these older versions upon installation of a new version?
Bundles piling up in an install folder are not really a problem - they will only use the space, but they are ignored by the Apache Sling OSGI installer that CQ uses to detect and install the bundles. The installer only considers the latest version of the bundle (based on its OSGi version header), and ignores older versions.
If you really want to remove the older bundle files, best is probably to create a small tool that finds them by walking the JCR tree under which they are installed (/apps I assume), and delete all but the latest version. If the bundle filenames consistently include the version number you can probably just sort their names with the right comparator and remove all but the last one. If you want to be really robust you'll need to read the bundle metadata to find out about its version number.
If you want to run your tool automatically at regular intervals you could register an OSGi EventHook to detect when new bundles are installed, and trigger a cleanup run when that happens.
Sorry if this sounds a bit complicated - but again leftover bundle files are not really problematic.
I solved the problem by configuring the filter.xml in my myproject-all module (see CQBlueprints description for the purpose of this module) to delete the contents of my bundle install folder. This way, old bundles are always deleted before new bundles are installed.
To delete the contents of my install folder, I added the following line to my filter.xml file:
<filter root="/apps/myapp/install">
use curl command to delete the specific bundle version.
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Edit: Removed purging as that was not applicable to the osgi bundle.

How to install maven toll for dependencies in netbeans in windows?

I recently started a project and learnt that I need to install depended packages manually and i'm very much lazy to do so. I searched and got Maven, but installation process is missing. How do I do it?
Download the latest Netbeans from here..
https://netbeans.org/downloads/
Maven is embedded in Netbeans, then you'd only create a new Maven project from the file menu... And you will manage you dependencies easily..
I have downloaded NetBeans new version when I try to create a new project, Maven Project is already there.

Karaf update bundles via xml feature file

Scenario:
a feature xml file that describe an application (V1.0) with a bundle (suppose gson) version 2.2.3
A second feature file with a newer application (V1.1) version and with a gson bundle version 2.2.4
they will install gson 2.2.3 and 2.2.4 side-by-side.
Question:
is it possible by means of xml file (i've seen the xsd and no hints for me there) to UPGRADE from V1.0 to V1.1 AND uninstall at same time the unnecessary gson 2.2.3
Short answer no, there is no upgrade. You might install the new and uninstall the old this way unneeded bundles might be uninstalled. Still If your dependencies are right your bundle should pick-up only the new version and not the old.
I've found a solution with some limitations. Using a KAR file for the whole project as a unique artifact will do the trick. Limitation is that KAR files/url repositories must have same name.

Need help in Installing JRE?

i have to install JRE Programmability if the System does not have JRE, i had dected JRE is installed in the system or not, but i have no idea how to install JRE programmtically, some people said you can use installer, but i donot know how to use installer for this purpose i searched in sun documnet, installing JRE in slient mode, there's also i donot know how to use that command iie.fing.edu.uy/ense/asign/…
In order to run your Java program, you can do that without installing the JRE, that its, you can run the application in a computer without JRE, we do that every day.
The way is to deploy you application with an embedded JRE and use a script (.bar, .sh) to execute you application using the embedded JRE. So your application is self-contained and no requires external JRE. You need to copy the entire JRE folder into your application and start removing unused files using the test-error approach. You can also decrease the file sizes removing not needed classes, like in rt.jar (you can decompress, remove unused classes and zip again).
The problem with this approach is that you are violating the Oracle/SUN JRE distribution policy as you are distributing a JRE with fewer files. If the application is for internal use, I think it's OK, if you want to redistribute the application, you are in trouble.
Another question is how to install the JRE by code, you can try to ship the JRE with your application, using an installer detect if JRE is already installed and install it id needed. Doing that in Java code is not trivial, you can use Runtime to exec external programs...
Do not rely on JAVA_HOMEas is not actively used nowadays.
Example:
Say you application name is 'A', you folder structure can look like:
A
|-> Run.bat
|- jre
|- bin
|- lib
|- lib
|-> A.jar
You application main class is Main.java in package a. Your Run.batcan look like START "" jre\bin\javaw.exe -cp lib\A.jar a.Main
You only are calling the embedded jre in jre folder, by calling the bin\javaw.exe and passing the jar and main class. The jre folder can content and entire JRE as copied from c:\Program Files (x86)\Java\jre6\ (Windows 7).
If you can have a web based solution you can use deployjava
http://download.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html

Resources