Accessing JRE extensions from Eclipse Plugin [message #323857] |
Thu, 10 January 2008 09:35  |
Eclipse User |
|
|
|
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 #323911 is a reply to message #323888] |
Sat, 12 January 2008 10:31  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.31961 seconds