How to add a plugin to JNode

This page will describe how to add a java program to JNode as plugin, so that it can be called via its alias.

First of all you need to set up Eclipse (or your favorit IDE) as described in the readme, so that JNode builds without errors and you can use it (e.g. use JNode in VMWare).

There are different ways of extending JNode with a plugin.
A plugin can contain a class that extends Plugin and (or) normal java programs.
Every plugin is described by a descriptor.

For our example we will develop a plugin that contains a normal java program.

We need a name for our plugin : we will use sample, wich is also the packagename of our plugin.
It belongs to one of the JNodes subprojects in our case we will use the ordername sample in the shell subproject.

Every java-file for our plugin has to be in (or in subfolders):



\shell\src\shell\org\jnode\shell\sample

(for me it is d:\jnode\shell\src\shell\org\jnode\shell\sample)



Now we will write a small HelloWorld.java wich will be one of our plugin programs.
Here is the source of the file HelloWorld.java :

package org.jnode.shell.sample;

public class HelloWorld{

        public static void main(String[] args){

            System.out.println(“HelloWorld – trickkiste@gmx.de“);

        }

}

thats ok, but it will not be build until we create a descriptor and add our plugin to the JNode full-plugin-list.xml.



The plugin descriptor (org.jnode.shell.sample.xml stored in the descriptors folder of the shell subproject) and looks like this :

<?xml version="1.0" encoding="UTF-8"? >

<!DOCTYPE plugin SYSTEM "jnode.dtd">


<plugin id="org.jnode.shell.sample"

            name="Sample Plugin"

            version="0.2"

            license-name="lgpl"

            provider-name="Trickkiste">

<requires>

            <import plugin="org.jnode.shell"/>

</requires>

<runtime>

            <library name="jnode-shell.jar">

                        <export name="org.jnode.shell.sample.*"/>

            </library>

</runtime>

<extension point="org.jnode.shell.aliases">

            <alias name="HelloWorld" class="org.jnode.shell.sample.HelloWorld"/>

</extension>

</plugin>

Now we need to add our Plugin to the JNode full-plugin-list.xml, this file is located in jnode\all\conf your entry should look like this :

[...]

            <plugin id="org.jnode.util"/>

            <plugin id="org.jnode.vm"/>

            <plugin id="org.jnode.vm.core"/>

            <plugin id="org.jnode.shell.sample"/>

</plugin-list>

thats it, you can now build JNode and test your HelloWorld plugin by typing HelloWorld.

What we can do now is add „normal“ programs to JNode via its provided Pluginstructure.