• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create first minimal Maven Project?

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see I jumped the gun a little. Let me concentrate on just getting a simple maven project to work and then come back to importing it into eclipse.


I have a simple minimal "hello world!" application generated by "maven genapp" version 1.1. It works.

As per http://jakarta.apache.org/commons/httpclient/downloads.html I experiment with adding one,the other or both dependencies. Nothing worked. I expected that it would work if I only downloaded 3.0. However, after more experiementation, I discovered I could successfully manually compile (and run) the sample code at http://jakarta.apache.org/commons/httpclient/tutorial.html if I added both jar files (hiding in my maven repository) to my class path. Here is my latest attempted at adding both to the project.xml file:


<dependencies>
<dependency>
<id>commons-httpclient</id>
<version>2.0.2</version>
<url>http://jakarta.apache.org/commons/httpclient/</url>;
</dependency>
<dependency>
<id>commons-httpclient</id>
<version>3.0-rc4</version>
<url>http://jakarta.apache.org/commons/httpclient/3.0/</url>;
</dependency>
</dependencies>

I compile and run again. I see that maven sees the new dependencies and downloads httpclient (which is odd, since it already downloaded them a couple of days ago). The program runs.

Now, as per http://jakarta.apache.org/commons/httpclient/tutorial.html I enhance hello world with some minimal code:

package mdn.testapp;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
HttpClient client = new HttpClient();
System.out.println( "Goodbye World!" );
}
}

I see "hello world". It dies on the "new HttpClient". Why? java is obviously not seeing those libraries. Maven is supposed to take care of that, however!

What am I doing wrong?

Thanks,
Siegfried
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if you have alrady got it to work. but s'dnt the dependency be specified like this?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic