Search code examples
javanetbeansjmf

Netbeans Platform Application doesnt detect webcam devices with JMF


I've been trying to develop an application with Netbeans RCP to grab images from a webcam. Plain and simple, it works in a regular Java project.

So first of all the JMF must be installed (I'm on Windows 7 64bit, (32bit JDK which is needed for JMF).

In a regular Java project I have the following code:

Vector webcams = CaptureDeviceManager.getDeviceList(null);
int length = webcams.size();
System.out.println("length: " +length); 

The output for this is "length: 1" (1 webcam connected)

When I do this in my Netbeans platform project this output is "length: 0".

So basicly I have my Netbeans project suite 2 modules:

  • JMF libraries (wrapper module with jmf.jar)
  • Webcam module (contains 1 java file with the above code)

I added the JMF libraries module to the Webcam module as a Dependency but this didn't do the trick. I can also confirm that the classpath is set:

Boot & Ext. Classpath   = C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\resources.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\rt.jar;
C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\sunrsasign.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\jsse.jar;
C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\jce.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\charsets.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\modules\jdk.boot.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\classes;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\dnsns.jar;**C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\jmf.ja**r;
C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\sound.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\sunjce_provider.jar;
C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jdk1.6.0_25\jre\lib\ext\sunpkcs11.jar

I am really stuck here. What is so special about Netbeans RCP that adding jmf.jar as a wrapper module seems to break this code?

If someone has some tips to help get more debug information to trace the problem I'm very grateful.

EDIT:

After a lot of trial and error I found the following solution:

Copy c:\Progra.... x86\JMF...\lib\* to c:\Program .. x86\jdk\lib\*
Including the jmf.properties file

However I am happy that this works, once the app transfer to another client PC for usage it will not have those libs there.

So I really don't know how to solve this problem with Netbeans RCP. How hard can it be? I added the jars to the wrapper, I placed the .properties file in the /release/modules/ext folder as well.

Please help me out here :)


Solution

  • You have to add into build.xml: (jmf.propeties have to be in COMPILED dist folder, near to Your your_jar.jar!!!)

    go to Files tab in Project Explorer, and add into build.xml

    (JMF by me is in c:\JMF...)

    <target name="-post-compile">
             <copy file="C:\JMF\lib\jmf.properties" todir="${dist.dir}"/>
        </target>