Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JDT editor can find my Jar on classpath, but launch cannot
JDT editor can find my Jar on classpath, but launch cannot [message #775312] Thu, 05 January 2012 18:52 Go to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
This is on Eclipse 3.6.1, I have not tried it on a more recent release, but my product needs to be supported on this older release if possible.

The problem I'm trying to solve is to allow my users to code against a Jar file I provide with my product. What I first did was just instruct them to put the Jar file on the classpath for their project. However, they did not get the javadoc, and worse, since the Jar file mainly provides interfaces, they also don't get the method arguments (it shows up as arg0, arg1, etc).

I already have a project in the workspace called Builtin that has files associated with my product. This project is read only and lives inside of a plugin, so I use the platform URL to get to its contents (see below). So I came up with the idea that I could just make this a Java project (adding the project nature), and put the Jar file and the classpath there so the Javadoc would be referenced (which also finds the arguments names). And this works great until I try to launch the application.

The details:

I have a project in the workspace (called Builtin) that uses a "platform" URL for its location:

platform:/plugin/com.oaklandsw.data.transform.builtin/Builtin/


The .classpath file for the project looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry exported="true" kind="lib" path="odtapi-3.2.0.jar">
        <attributes>
            <attribute name="javadoc_location" value="platform:/plugin/com.oaklandsw.transform.doc7/javadocs"/>
        </attributes>
    </classpathentry>
</classpath>


I then reference this project from another project (called TestJava), so the other project's classpath looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
	<classpathentry combineaccessrules="false" kind="src" path="/Builtin"/>
	<classpathentry kind="output" path="bin"/>
</classpath>


I then make a class in TestJava and am able to reference the classes from Builtin just fine, the Javadoc is all hooked up, everything looks great.

However when I run my class in TestJava, I get the following error (using the default Java Application launch context):

The archive: /Builtin/odtapi-3.2.0.jar which is referenced by the classpath, does not exist.


I suspect I'm getting this error because the design time resolution of the project's classpath using my funny URL works OK, but the runtime classpath resolution cannot deal with this URL. In my project I have an EFS handler for the platform: URL scheme which seems to work fine in all other cases (indeed the design time JDT sees everything it needs to).

The next thing I thought I would try was to use a "var" type in the classpath that looked like this:

    <classpathentry exported="true" kind="var" path="ECLIPSE_HOME/plugins/com.oaklandsw.data.transform.builtin_3.2.0.I20120105-0423/Builtin/odtapi-3.2.0.jar">


While I think this would probably solve this problem in some cases, since we are having the launcher use a real file reference, I don't think this is a workable solution because you can't be sure where p2 is actually going to be putting the plugins in the file system in all cases.

I'm open to any other way of solving this.

Thanks for reading and happy new year!
Francis






Re: JDT editor can find my Jar on classpath, but launch cannot [message #775613 is a reply to message #775312] Fri, 06 January 2012 11:09 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 05.01.2012 19:52, Francis Upton wrote:
> This is on Eclipse 3.6.1, I have not tried it on a more recent
> release, but my product needs to be supported on this older release if
> possible.
>
> The problem I'm trying to solve is to allow my users to code against a
> Jar file I provide with my product. What I first did was just instruct
> them to put the Jar file on the classpath for their project.
You mean 'Java Build Path', right?
> However, they did not get the javadoc, and worse, since the Jar file
> mainly provides interfaces, they also don't get the method arguments
> (it shows up as arg0, arg1, etc).
You also need to provide the source or the Javadoc.

Two other ways to provide the library:

- put them into its own bundle
- provide a library container (see
'org.eclipse.jdt.core.classpathContainerInitializer' and
'org.eclipse.jdt.ui.classpathContainerPage')

Dani
>
> I already have a project in the workspace called Builtin that has
> files associated with my product. This project is read only and lives
> inside of a plugin, so I use the platform URL to get to its contents
> (see below). So I came up with the idea that I could just make this a
> Java project (adding the project nature), and put the Jar file and the
> classpath there so the Javadoc would be referenced (which also finds
> the arguments names). And this works great until I try to launch the
> application.
>
> The details:
>
> I have a project in the workspace (called Builtin) that uses a
> "platform" URL for its location:
>
>
> platform:/plugin/com.oaklandsw.data.transform.builtin/Builtin/
>
>
> The .classpath file for the project looks like this:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry exported="true" kind="lib" path="odtapi-3.2.0.jar">
> <attributes>
> <attribute name="javadoc_location"
> value="platform:/plugin/com.oaklandsw.transform.doc7/javadocs"/>
> </attributes>
> </classpathentry>
> </classpath>
>
>
> I then reference this project from another project (called TestJava),
> so the other project's classpath looks like this:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <classpath>
> <classpathentry kind="src" path="src"/>
> <classpathentry kind="con"
> path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
> <classpathentry combineaccessrules="false" kind="src" path="/Builtin"/>
> <classpathentry kind="output" path="bin"/>
> </classpath>
>
>
> I then make a class in TestJava and am able to reference the classes
> from Builtin just fine, the Javadoc is all hooked up, everything looks
> great.
>
> However when I run my class in TestJava, I get the following error
> (using the default Java Application launch context):
>
>
> The archive: /Builtin/odtapi-3.2.0.jar which is referenced by the
> classpath, does not exist.
>
>
> I suspect I'm getting this error because the design time resolution of
> the project's classpath using my funny URL works OK, but the runtime
> classpath resolution cannot deal with this URL. In my project I have
> an EFS handler for the platform: URL scheme which seems to work fine
> in all other cases (indeed the design time JDT sees everything it
> needs to).
>
> The next thing I thought I would try was to use a "var" type in the
> classpath that looked like this:
>
>
> <classpathentry exported="true" kind="var"
> path="ECLIPSE_HOME/plugins/com.oaklandsw.data.transform.builtin_3.2.0.I20120105-0423/Builtin/odtapi-3.2.0.jar">
>
>
> While I think this would probably solve this problem in some cases,
> since we are having the launcher use a real file reference, I don't
> think this is a workable solution because you can't be sure where p2
> is actually going to be putting the plugins in the file system in all
> cases.
>
> I'm open to any other way of solving this.
>
> Thanks for reading and happy new year!
> Francis
>
>
>
>
>
Previous Topic:space in java editor does now show properly
Next Topic:Create fully-featured IJavaCompletionProposal from IMethod
Goto Forum:
  


Current Time: Tue Apr 23 09:19:03 GMT 2024

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

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

Back to the top