SDU m-drive Personal Network Folder on Linux Machines

I’ve written this guide before somewhere, but always fails to find it when I need it, so here is again. A guide for students and employees at University of Southern Denmark SDU for mounting their personal folder, the m-drive, on a Linux machine.

First step is to figure out what the path to your m-drive is… on a Windows machine find the folder, right click and select properties. On the tab “DFS” there is a full path to the folder. The path displayed in the title bar, which includes something like “\dfs\data” in it, is not the right one. For employees of the Technical Faculty the path currently is: “\\tek-data0a.tek.c.sdu.dk\tekansatte”

You need “smbfs” and “cifs-utils” installed on your machine. On an Ubuntu machine write: “sudo apt-get install smbfs” in a terminal and you’ll get all the necessary components.

You can now mount the m-drive from a terminal with the following command:

sudo mount -t cifs -o username=<username>,domain=<domain>,password=<password>,iocharset=utf8,codepage=unicode,uid=1000,gid=1000 //tek-data0a.tek.c.sdu.dk/tekansatte/<username> /mnt

where you need to change <username>, <password> and <domain> to reflect your information. Also the path, in this case “//tek-data0a.tek.c.sdu.dk/tekansatte/<username>” should be changed to what you were seeing in the properties of the m-drive. Notice the backslashes have been changed into forward slashes.

For a permanent mount add the following to fstab:

//tek-data0a.tek.c.sdu.dk/tekansatte/<username>       /var/m-drive    cifs    credentials=/root/.smbpasswd_mdrive,_netdev,iocharset=utf8,codepage=unicode,uid=1000,gid=1000

where the credentials are stored in a file in the /root folder.

See here, here and here for more information, including credentials, _netdev and isocharset.

Reflection problem in the Netbeans Nodes API tutorial

I’ve been following the Netbeans tutorial on using the Nodes API to implement a tree structure with some information in it.

In the second part of the tutorial the author shows how to set up and show a property sheet sheet when an element in the tree structure is selected. Most of the examples work pretty straight forward, but when I tried to adapt the example to my own code, I got a problem with the way the tutorial uses the Java reflection to set the fields of the property sheet. Here is the line in the tutorial:

APIObject obj = getLookup().lookup(APIObject.class);
Property indexProp = new PropertySupport.Reflection(obj, Integer.class, "getIndex", null);

When ever I try to do that with my own implementation of an APIObject, I get a NoSuchMethodException. After trying to work out why that was happening, without any success, I figured another way to create the property sheet, based on this blog post: http://blogs.oracle.com/geertjan/entry/connecting_shapes_showing_properties by Geertjan Wielenga from the Netbeans group.

The code becomes like this instead:

APIObject obj = getLookup().lookup(APIObject.class);
Property indexProp = new PropertySupport.ReadOnly("objIndex" Integer.class,"Index","Object index") { 
 
@Override
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
 return obj.getIndex();
}
};

While that is not really a solution to the non-working reflection, it is still a workaround that can be used.

Adding javadoc to JAR files in a Netbeans project

The other day I was working on a Netbeans project where I had to create a new module that was dependent on a external JAR file. From the platform document I found out that you can add a JAR file in two ways: Using the Library Manager or using a Library Wrapper Module. First I tried the second option, and it worked fine except for one thing – there was no javadoc attached to the jar, and no way to attach it.

Project Properties

There is no way to edit the jar file properties

Then I tried the other option, adding the JAR as a library using the Libraries option from the Tools menu. Using this method it was possible to add both the javadoc and the source to the library. Unfortunately there was no way to include the library in a project, which kind of renders the whole ting useless. I still don’t know what the Library Manager is supposed to be used for, but apparently not for including JARs in projects.

After Googling for a while, coming up blank on what to do, I got in touch with a Netbeans expert Andrzej Olszak – author of the cool Featureous tool. He already knew the problem from his own work and also knew a work-around:

  1. Select the main module suite, click the New Project… option in the file menu and add a new Library Wrapper Module
  2. Select the JAR file to be included and complete the forms as needed. When you press OK, the new module should be opened along with your other modules.
  3. Right click on the module in the list of projects and select Properties at the bottom of the menu. Select the Libraries node on the left side, and click on the Wrapped JARs tab to the right.
  4. Now you see the same options as on the image above, with the Edit… button disabled. Here comes the trick:
  5. Select the JAR and press Remove, then press the Add JAR button and re-add the same JAR file again… and watch what happens to the Edit… button. Suddenly it is enabled! That is it…

Now you can include the wrapper module as a dependency in any module you like, and the javadoc will be available.

Javadoc for an included JAR file in Netbeans

Now the javadoc is visible...