Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Accessing JRE extensions from Eclipse Plugin
Accessing JRE extensions from Eclipse Plugin [message #323857] Thu, 10 January 2008 09:35 Go to next message
Eclipse UserFriend
Originally posted by: tas.frangoullides.barclaysglobal.com

Hi,

I'm developing an application that needs COM port communication and I'm
trying to do this using the Sun Java Communications API.

I'm able to install the the Java Communications API files into a JRE and
set this as the target JRE and develop code against the API. Running the
code as a java application works as expected.

However, if I try run the same code within an Eclipse Application (or
JUnit Plugin Test) the code fails with a NoClassDefFoundError. Apparently
the launched eclipse environment can't see the additional libraries.

Is there something special I need to do to the launch configuration?

Thanks for your help,
Tas

java.lang.NoClassDefFoundError: javax/comm/NoSuchPortException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.getMethod0(Class.java:2611)
at java.lang.Class.getMethod(Class.java:1579)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoade r.getTest(JUnit3TestLoader.java:99)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoade r.loadTests(JUnit3TestLoader.java:59)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:445)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:58)
at
org.eclipse.pde.internal.junit.runtime.CoreTestApplication.r un(CoreTestApplication.java:24)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Re: Accessing JRE extensions from Eclipse Plugin [message #323858 is a reply to message #323857] Thu, 10 January 2008 09:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I'm not an OSGi-Expert but if those are not part of the standard JRE I
think you need to add import statements to your MANIFEST.MF.

Do they need to be installed in the JRE or why don't you ship them with
your plugin directly?

Tom

Tas Frangoullides schrieb:
> Hi,
>
> I'm developing an application that needs COM port communication and I'm
> trying to do this using the Sun Java Communications API.
> I'm able to install the the Java Communications API files into a JRE and
> set this as the target JRE and develop code against the API. Running the
> code as a java application works as expected.
>
> However, if I try run the same code within an Eclipse Application (or
> JUnit Plugin Test) the code fails with a NoClassDefFoundError.
> Apparently the launched eclipse environment can't see the additional
> libraries.
> Is there something special I need to do to the launch configuration?
>
> Thanks for your help,
> Tas
>
> java.lang.NoClassDefFoundError: javax/comm/NoSuchPortException
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
> at java.lang.Class.getMethod0(Class.java:2611)
> at java.lang.Class.getMethod(Class.java:1579)
> at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoade r.getTest(JUnit3TestLoader.java:99)
>
> at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoade r.loadTests(JUnit3TestLoader.java:59)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:445)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> at
> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:58)
>
> at
> org.eclipse.pde.internal.junit.runtime.CoreTestApplication.r un(CoreTestApplication.java:24)
>
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
> at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
> at org.eclipse.core.launcher.Main.run(Main.java:977)
> at org.eclipse.core.launcher.Main.main(Main.java:952)
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Accessing JRE extensions from Eclipse Plugin [message #323888 is a reply to message #323858] Fri, 11 January 2008 04:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tas.frangoullides.barclaysglobal.com

Hi Tom,

Thanks for helping out.

I tried adding an import-package statement to the MANIFEST.MF but I get
the following buildtime error in the manifest editor "No Available Bundle
Exports 'javax.comm'. This kind of makes sense becuase the library is not
in a bundle - it's part of the JRE.

I would like to package the communication API into a plugin if possible
but I don't know how to do that for this type of library. There are a few
components to the install.
1) Win32com.dll - this goes in the bin folder
2) javax.com.properties - this goes in the lib floder
3) comm.jar - this goes in the lib/ext folder

The stangest things is that the libraries are visible to the compiler,
everything compiles and that running my tests as "JUnit Test" works fine.
It's only when I run as "JUnit Plug-in Test" that things don't work and I
get the NoClassDefFoundError.

Thanks,
Tas
Re: Accessing JRE extensions from Eclipse Plugin [message #323911 is a reply to message #323888] Sat, 12 January 2008 10:31 Go to previous message
Eclipse UserFriend
Originally posted by: rkuzsma.gmail.com

I have a little experience trying to get native DLLs and third party .jar
files to work. Here's an example plug-in project that exports a .jar file
so other plug-ins can use it.

Example build.properties looks like this:
source.. = .
output.. = .
bin.includes = META-INF/,\
.,\
ThirdParty.jar

ThirdParty.jar MUST live in the root directory of the plug-in.

META-INF/MANIFEST.MF looks like this:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My ThirdParty Jar Wrapper Plug-in
Bundle-SymbolicName: com.myCompany.lib3rdparty
Bundle-Version: 1.0.0.0
Bundle-Vendor: My Company, Inc.
Bundle-Localization: plugin
Eclipse-LazyStart: true
Bundle-ClassPath: ThirdParty.jar
.
Export-Package: com.thirdParty.package1,
com.thirdParty.package2,
com.thirdParty.package3



As far as I know, the .classpath file does NOT need to explicitly export
the ThirdParty.jar, too, i.e.:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry exported="true" kind="lib" path="ThirdParty.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path=""/>
</classpath>

But it doesn't hurt.

Plug-ins are built using the PDE build, Java projects are build using the
Java build. Both have different ways of specifying a classpath
(essentially, Java projects use .classpath, Plug-in projects use
Manifest.mf).

As for accessing the native DLL: There's a Manifest.mf header called
Bundle-NativeCode that you might have to use. Although, I've had more
success just putting the native .dll in my plug-in's root. Also, to
simplify your life, don't include any .java source files in this Third
Party plug-in project.

And, if you're installing the plug-in project on someone's machine, do not
install the whole plug-in as a .JAR. Instead, unpack the plug-in to a
folder in the eclipse/plugins directory. Or, if there's a corresponding
feature project, specify unpack="true" in it. At least for me in Eclipse
3.2, I can only get third party .jar files and native dlls to load if I
install their host plug-in into its own folder.
Previous Topic:existing versions of plugin causing build conflicts
Next Topic:PDE finding source for BND-wrapped jars
Goto Forum:
  


Current Time: Wed Jul 16 11:54:08 EDT 2025

Powered by FUDForum. Page generated in 0.31961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top