Am Montag, den 24.11.2008, 22:38 -0800 schrieb Wayne Fay:
> > The problem I have now is, that I don't know how to run my application
> > once it is built with, say 'mvn package'. I tried 'java -jar
> 
> People generally use the assembly plugin for this purpose.
> http://maven.apache.org/plugins/maven-assembly-plugin/
> 
> > my.package.MainClass', but then it doesn't find any resources I try to
> > load in my code with
> > "this.getClass().getClassLoader().getResource(...)". All resources are
> 
> John Casey sent this method a while ago that might be useful:
> 
> private File getFile( String resourceName )
> {
>  ClassLoader cloader = Thread.currentThread().getContextClassLoader();
>  URL resource = cloader.getResource( resourceName );
>  if ( resource == null )
>  {
>      throw new IllegalArgumentException( "Could not get resource: " +
> resourceName );
>  }
>  return new File( resource.getPath() );
> }
> 
> Wayne
> 

Thank you (and Peter). The assembly plugin is exactly what I was looking
for.

The method for getting file resources seems to work well. I think I even
understand what is causing all the problems with the different
getResource() methods, but then I still wonder why it has to be this
complicated... but thats a completely different subject, which doesn't
even belong here I think.

Simon

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to