You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by SingleShot <mi...@gmail.com> on 2006/10/25 00:15:24 UTC
Add Directory to Jar Manifest Classpath
I am building an executable JAR that depends on a handful of other JARs and a
few config files being on the classpath. I want the config files to be
editable by the end user, so did not add them as internal JAR resources.
I've configured the maven-jar-plugin to generate a manifest and add the
dependencies to its classpath (and create a mainclass entry), but cannot
figure out how to configure it to add my config directory (containing the
config files) to the classpath.
Is it possible to add a directory to the classpath of a Maven-generated
Manifest?
Thanks in advance.
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a6982645
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by pjungwir <ma...@9stmaryrd.com>.
That's a very handy command! You're right, it says 2.1. Yesterday I tried
running with -X, and I thought it said it was getting 2.2, but now -X also
says 2.1, so I must have made a mistake. My apologies!
But the trailing slash still works on my system. :-) But I'm running linux,
and the bug is filed against windows....
Paul
Syvalta wrote:
>
>
> pjungwir wrote:
>>
>> I don't understand. 2.2 is the plugin version, not the maven version,
>> right? That appears to be released. For me, it's what maven just uses; I
>> didn't do anything special.
>>
>
> Yes, the version of jar-plugin. To my knowledge 2.1 is the latest version
> (see
> http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/).
> Jira lists both 2.1 and 2.2 unreleased ( which is wrong for the latter).
> Are you sure you have checked the version of the correct plugin? Yuo can
> check the version with command "mvn -Dplugin=jar help:describe".
>
>
>
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7016303
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by Syvalta <sy...@yahoo.com>.
pjungwir wrote:
>
> I don't understand. 2.2 is the plugin version, not the maven version,
> right? That appears to be released. For me, it's what maven just uses; I
> didn't do anything special.
>
Yes, the version of jar-plugin. To my knowledge 2.1 is the latest version
(see
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/).
Jira lists both 2.1 and 2.2 unreleased ( which is wrong for the latter). Are
you sure you have checked the version of the correct plugin? Yuo can check
the version with command "mvn -Dplugin=jar help:describe".
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7016118
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by pjungwir <ma...@9stmaryrd.com>.
I don't understand. 2.2 is the plugin version, not the maven version, right?
That appears to be released. For me, it's what maven just uses; I didn't do
anything special.
Paul
Syvalta wrote:
>
>
> pjungwir wrote:
>>
>>
>> Syvalta wrote:
>>>
>>> But that doesn't work for me, see:
>>> http://jira.codehaus.org/browse/MJAR-60.
>>>
>> I didn't get any error with a trailing slash inside <Class-Path>. JIRA
>> says this is fixed against 2.2. I'm not sure why the bug is still open in
>> that case. . . .
>>
>
> There isn't snapshot of 2.2 yet, so I didn't test with that, so I can't
> confirm. However, as I understand it, "fix for" means that is should be
> fixed before that release, not that it's fixed.
>
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7014719
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by Syvalta <sy...@yahoo.com>.
pjungwir wrote:
>
>
> Syvalta wrote:
>>
>> But that doesn't work for me, see:
>> http://jira.codehaus.org/browse/MJAR-60.
>>
> I didn't get any error with a trailing slash inside <Class-Path>. JIRA
> says this is fixed against 2.2. I'm not sure why the bug is still open in
> that case. . . .
>
There isn't snapshot of 2.2 yet, so I didn't test with that, so I can't
confirm. However, as I understand it, "fix for" means that is should be
fixed before that release, not that it's fixed.
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7006293
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by pjungwir <ma...@9stmaryrd.com>.
Syvalta wrote:
>
> But that doesn't work for me, see:
> http://jira.codehaus.org/browse/MJAR-60.
>
I didn't get any error with a trailing slash inside <Class-Path>. JIRA says
this is fixed against 2.2. I'm not sure why the bug is still open in that
case. . . .
Paul
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7001786
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by Syvalta <sy...@yahoo.com>.
SingleShot wrote:
>
> Is it possible to add a directory to the classpath of a Maven-generated
> Manifest?
>
In theory, yes:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.foo.mainclass</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>config/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
But that doesn't work for me, see: http://jira.codehaus.org/browse/MJAR-60.
Another limitation (in java, not in maven) is that you can't access higher
level directories, so something like <Class-Path>../config/</Class-Path>
won't work.
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a6987252
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by pjungwir <ma...@9stmaryrd.com>.
Oh, I'm sorry, I thought you were saying that the Class-Path entry in the
manifest couldn't refer to non-jar items. It's very easy to set the
Class-Path entry using either the jar plugin or the assembly plugin. In the
<configuration> section, specify an <archive> element. The jar plugin has
pretty good docs for this. If you want maven to include your dependencies,
say this:
<archive>
<manifest>
<mainClass>com.example.App</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
To give your own classpath (or prepend to what maven writes), do this:
<archive>
...
<manifestEntries>
<Class-Path>config/ classes/</Class-Path>
</manifestEntries>
</archive>
But note that currently the assembly plugin has a bug and ignores
<manifestEntries>. The jar plugin does not have this bug.
Paul
berndq wrote:
>
> Hi,
>
>> Are you sure that documentation wasn't talking about applets? I've run
>> executable jars with Class-Path manifest entries referencing the
>> filesystem
>> many times.
>
> I looked it up again:
>
> http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html
> goto -jar option, there it says
> "When you use this option [Main-Class:classname], the JAR file is the
> source of all user classes, and other user class path settings are
> ignored."
>
> I was trying to extend the classpath from outside the jar (-cp xxx)
> and this is what does not work according to the specs.
>
> I did not try to extend the classpath in the manifest inside the jar.
> Is this possible at all when using the assembly plugin the create the
> classpath entry in the manifest?
>
> thanks for you info!
>
> Bernd
>
>> Paul
>>
>>
>> berndq wrote:
>>> SingleShot wrote:
>>>> I am building an executable JAR that depends on a handful of other JARs
>>>> and a
>>>> few config files being on the classpath. I want the config files to be
>>>> editable by the end user, so did not add them as internal JAR
>>>> resources.
>>>> I've configured the maven-jar-plugin to generate a manifest and add the
>>>> dependencies to its classpath (and create a mainclass entry), but
>>>> cannot
>>>> figure out how to configure it to add my config directory (containing
>>>> the
>>>> config files) to the classpath.
>>>>
>>>> Is it possible to add a directory to the classpath of a Maven-generated
>>>> Manifest?
>>> Hi,
>>>
>>> I had exactly the same problem. This is not a maven but a (sun?) Java
>>> problem:
>>>
>>> Executable jars use a classloader that can only load resources/classes
>>> from other jars and not from the file system. I found this documented
>>> somewhere under java.sun.com.
>>>
>>>
>>> So I had to stop using executable jars :-(
>>>
>>> best regards
>>> Bernd
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7031994
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by berndq <be...@gmx.net>.
Hi,
> Are you sure that documentation wasn't talking about applets? I've run
> executable jars with Class-Path manifest entries referencing the filesystem
> many times.
I looked it up again:
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html
goto -jar option, there it says
"When you use this option [Main-Class:classname], the JAR file is the
source of all user classes, and other user class path settings are ignored."
I was trying to extend the classpath from outside the jar (-cp xxx)
and this is what does not work according to the specs.
I did not try to extend the classpath in the manifest inside the jar.
Is this possible at all when using the assembly plugin the create the
classpath entry in the manifest?
thanks for you info!
Bernd
> Paul
>
>
> berndq wrote:
>> SingleShot wrote:
>>> I am building an executable JAR that depends on a handful of other JARs
>>> and a
>>> few config files being on the classpath. I want the config files to be
>>> editable by the end user, so did not add them as internal JAR resources.
>>> I've configured the maven-jar-plugin to generate a manifest and add the
>>> dependencies to its classpath (and create a mainclass entry), but cannot
>>> figure out how to configure it to add my config directory (containing the
>>> config files) to the classpath.
>>>
>>> Is it possible to add a directory to the classpath of a Maven-generated
>>> Manifest?
>> Hi,
>>
>> I had exactly the same problem. This is not a maven but a (sun?) Java
>> problem:
>>
>> Executable jars use a classloader that can only load resources/classes
>> from other jars and not from the file system. I found this documented
>> somewhere under java.sun.com.
>>
>>
>> So I had to stop using executable jars :-(
>>
>> best regards
>> Bernd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by pjungwir <ma...@9stmaryrd.com>.
Are you sure that documentation wasn't talking about applets? I've run
executable jars with Class-Path manifest entries referencing the filesystem
many times.
Paul
berndq wrote:
>
> SingleShot wrote:
>> I am building an executable JAR that depends on a handful of other JARs
>> and a
>> few config files being on the classpath. I want the config files to be
>> editable by the end user, so did not add them as internal JAR resources.
>> I've configured the maven-jar-plugin to generate a manifest and add the
>> dependencies to its classpath (and create a mainclass entry), but cannot
>> figure out how to configure it to add my config directory (containing the
>> config files) to the classpath.
>>
>> Is it possible to add a directory to the classpath of a Maven-generated
>> Manifest?
>
> Hi,
>
> I had exactly the same problem. This is not a maven but a (sun?) Java
> problem:
>
> Executable jars use a classloader that can only load resources/classes
> from other jars and not from the file system. I found this documented
> somewhere under java.sun.com.
>
>
> So I had to stop using executable jars :-(
>
> best regards
> Bernd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Add-Directory-to-Jar-Manifest-Classpath-tf2504507.html#a7019847
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Add Directory to Jar Manifest Classpath
Posted by berndq <be...@gmx.net>.
SingleShot wrote:
> I am building an executable JAR that depends on a handful of other JARs and a
> few config files being on the classpath. I want the config files to be
> editable by the end user, so did not add them as internal JAR resources.
> I've configured the maven-jar-plugin to generate a manifest and add the
> dependencies to its classpath (and create a mainclass entry), but cannot
> figure out how to configure it to add my config directory (containing the
> config files) to the classpath.
>
> Is it possible to add a directory to the classpath of a Maven-generated
> Manifest?
Hi,
I had exactly the same problem. This is not a maven but a (sun?) Java
problem:
Executable jars use a classloader that can only load resources/classes
from other jars and not from the file system. I found this documented
somewhere under java.sun.com.
So I had to stop using executable jars :-(
best regards
Bernd
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org