<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SolitaryGeek &#187; tutorial</title>
	<atom:link href="http://solitarygeek.com/tag/tutorial/feed" rel="self" type="application/rss+xml" />
	<link>http://solitarygeek.com</link>
	<description>James Selvakumar&#039;s Blog</description>
	<lastBuildDate>Tue, 21 Dec 2010 04:35:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>NetBeans and Maven &#8211; A quick start guide</title>
		<link>http://solitarygeek.com/java/netbeans-and-maven-a-quick-start-guide</link>
		<comments>http://solitarygeek.com/java/netbeans-and-maven-a-quick-start-guide#comments</comments>
		<pubDate>Sun, 26 Sep 2010 07:30:22 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[logback]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[pom]]></category>
		<category><![CDATA[quick start]]></category>
		<category><![CDATA[slf4j]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://solitarygeek.com/?p=551</guid>
		<description><![CDATA[<p>A few months ago, I was reading the book &#8220;Wicket in Action&#8221;. I was new to Wicket and Maven then. I followed the instructions given in the book to create a maven project. The book went one step further and explained how to create eclipse and idea projects from the pom, but nothing was mentioned about NetBeans. I felt sad that there is no maven plugin out there to create projects that NetBeans can understand.</p> <p>But later when I realized that there is no such need to create Netbeans projects from Maven pom, I was thrilled. Maven, is a first <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/netbeans-and-maven-a-quick-start-guide">NetBeans and Maven &#8211; A quick start guide</a></span>]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I was reading the book &#8220;Wicket in Action&#8221;. I was new to Wicket and Maven then. I followed the instructions given in the book to create a maven project. The book went one step further and explained how to create eclipse and idea projects from the pom, but nothing was mentioned about NetBeans. I felt sad that there is no maven plugin out there to create projects that NetBeans can understand.</p>
<p>But later when I realized that there is no such need to create Netbeans projects from Maven pom, I was thrilled. Maven, is a first class citizen in NetBeans. Any Maven project &#8220;<strong>is a</strong>&#8221; NetBeans project.</p>
<p>Over the months, as I continued to learn and use Maven, NetBeans made the the learning curve easy. So I thought of putting up this post to benefit new Maven users.</p>
<p><strong>Setup</strong></p>
<p>If you are using Maven for the first time, you may want to download and install it on your machine.</p>
<p>Though NetBeans comes with an embedded Maven instance (version 3.0-SNAPSHOT in NetBeans 6.9 at the time of writing this post), it&#8217;s still a good idea to have your own Maven instance, so that you can use it outside the IDE as well.</p>
<p>Installing Maven is quite easy. Download the latest Maven distribution (version 2.2.1 at the time of writing) and follow the installation instructions for your operating system.</p>
<p>Now, let&#8217;s quickly dive into action by firing up the IDE and create a new Maven project.</p>
<p><strong>Creating a new Maven project</strong></p>
<p>Open NetBeans IDE and click &#8220;File -&gt; New Project&#8221; and then choose &#8220;Maven&#8221; as the category and &#8220;Maven Project&#8221; as the project type.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-1.png" alt="NetBeans Maven Project - Step 1" width="747" height="506" /></p>
<p>In the next step, select &#8220;Maven Quickstart Archetype&#8221; as the maven archetype.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-2.png" alt="NetBeans Maven Project - Step 2" width="747" height="506" /></p>
<p>Finally, enter other details of your project and finish the wizard.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-3.png" alt="NetBeans Maven Project - Step 3" width="747" height="506" /></p>
<p>That should leave you with a new Maven project with a structure similar to this:</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-4.png" alt="NetBeans Maven Project - Step 4" width="286" height="261" /></p>
<p>One thing I like about NetBeans is that it always gives you some workable defaults whether it&#8217;s a web project or a simple java project.</p>
<p>No difference here. Just right click the java source file the IDE generated for you to watch your Maven project in action.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-5.png" alt="" width="668" height="313" /></p>
<p>And this is the default &#8220;pom.xml&#8221; the IDE generated for you:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;

&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;examples.maven&lt;/groupId&gt;
&lt;artifactId&gt;hellomaven&lt;/artifactId&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;name&gt;hellomaven&lt;/name&gt;
&lt;url&gt;http://maven.apache.org&lt;/url&gt;

&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;junit&lt;/groupId&gt;
&lt;artifactId&gt;junit&lt;/artifactId&gt;
&lt;version&gt;3.8.1&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;/project&gt;
</pre>
<p>If you know Maven already, you know what&#8217;s happening. Even if you are new to Maven, there is nothing to worry. Every Maven project needs a few mandatory definitions and that&#8217;s what you are seeing now.</p>

<p><strong>Improving the default project</strong></p>
<p>There are a couple of things we can improve in this project. First let us cleanup the &#8220;pom.xml&#8221;. As you can see, a depedency to junit 3.8.1 has been declared in the pom. That&#8217;s pretty archaic and let us change the junit version to the latest available version.</p>
<p>You need not scratch your head to figure out what&#8217;s the latest version of junit. The IDE is right there to help you. Keep the cursor near the version element and invoke the code completion by pressing the appropriate key. (In my case it&#8217;s CTRL + SPACE). Now, the IDE should give you a list of available junit versions in the default Maven remote repository.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-61.png" alt="" width="357" height="343" /></p>
<p>Choose the latest available junit version and save the details.</p>
<p>Let us rewrite the test case making use of the recent junit enhancements. Delete the existing unit test class and create a new one by right clicking the java source file and then selecting &#8220;Tools -&gt; Create Junit Tests&#8221;. You should see the IDE displaying a dialog saying that it cannot create junit 4.x tests.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-7.png" alt="" width="351" height="180" /></p>
<p>There is nothing wrong with the IDE here. Because JUnit 4.x makes use of annotations and hence need a Java source level of 1.5 or above. By default, Maven doesn&#8217;t assume your source files to be 1.5 compatible, so you need to tell Maven exactly what Java source version you would be using in your projects. Doing that is quite simple. Open the project&#8217;s &#8220;pom.xml&#8221; in the editor and define the Java source level like this.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;

&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;examples.maven&lt;/groupId&gt;
&lt;artifactId&gt;hellomaven&lt;/artifactId&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;name&gt;hellomaven&lt;/name&gt;
&lt;url&gt;http://maven.apache.org&lt;/url&gt;

&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;junit&lt;/groupId&gt;
&lt;artifactId&gt;junit&lt;/artifactId&gt;
&lt;version&gt;4.8.1&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;source&gt;1.6&lt;/source&gt;
&lt;target&gt;1.6&lt;/target&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;

&lt;/project&gt;
</pre>
<p>You should be able to create JUnit 4.x tests from the IDE now.</p>
<p>Applying &#8220;Test Driven Development&#8221; to our project, let us create an unit test for an non-existent method in the java source.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-8.png" alt="" width="398" height="155" /></p>
<p>And now write the actual method in the java source so that the IDE doesn&#8217;t complain about the errors in our unit test.</p>
<pre class="brush: java; title: ; notranslate">

protected String sayHello(String input)
{
String output = &quot;Hello &quot; + input;
return output;
}
</pre>
<p>Go back to the unit test and run it.(I usually type CTRL + F6 to run the unit tests). Congrats! Your Maven project is seriously ready for prime time.</p>
<p>Do not take me wrong but it&#8217;s really a good practice to write unit tests for everything and that&#8217;s why I bothered you with this stuff.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-9.png" alt="" width="396" height="107" /></p>
<p><strong>Don&#8217;t use System.out.println!<br />
</strong></p>
<p>Though we are already familiar with dependencies, we only used JUnit which is a test dependency. And this is a good time to dive into the dependency hell by introducing our next dependency to this little project, &#8220;slf4j&#8221; or &#8220;Simple Logging Facade for Java&#8221;.</p>
<p>It&#8217;s hard to imagine any project without &#8220;logging&#8221; and our example project is no exception. (Heck, what&#8217;s there to log in this project???)</p>
<p>And with &#8220;slf4j&#8221; gaining wide spread adoption, let us make use of it. &#8220;slf4j&#8221; doesn&#8217;t tie our application to any logging framework (other than itself <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ). It&#8217;s something like &#8220;jpa&#8221;. It gives you the freedom to choose your own logging provider. (My current favourite is logback)</p>
<p>Enough talking, let us starting using logging in our project.</p>
<p>To justify the use of logging, let us create some opportunity by updating our &#8220;main&#8221; method.</p>
<pre class="brush: java; title: ; notranslate">

public static void main(String[] args)
{
if(args != null &amp;&amp; args.length &gt; 0)
{
System.out.println(new App().sayHello(args[0]));
}else{
System.out.println(&quot;You have to pass atleast one argument to get a warm response from me!&quot;);
}
}
</pre>
<p>Time to fix those &#8220;System.out.println&#8221; calls by using slf4j. Create a slf4j Logger instance.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-10.png" alt="" width="652" height="23" /></p>
<p>That&#8217;s obvious. By no way the IDE can figure out what is happening here apart from resolving the &#8220;Logger&#8221; to java.util.logging which is not our objective.</p>
<p>Now click the edison&#8217;s bulb in the gutter to see what magic the IDE has under it&#8217;s hat.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-11.png" alt="" width="650" height="167" /></p>
<p>Select the option &#8220;Search Dependency at Maven Repositories&#8230;&#8221;. The IDE should popup a window with the possible matching artifacts.</p>
<p>Scroll to the bottom and locate &#8220;slf4j-api&#8221; and click &#8220;Add&#8221;. This will add the latest version of slf4j-api as a dependency. If you want to be more specific on the version, you can expand the slf4j-api node and choose the appropriate version.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-12.png" alt="" width="456" height="396" /></p>
<p>Go back to your &#8220;pom.xml&#8221; and see a new dependency for &#8220;slf4j-api&#8221; has been added. If you don&#8217;t want all this hassle, you can straight away add the following snippet in your pom.xml to add a dependency for slf4j-api.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;dependency&gt;
&lt;groupId&gt;org.slf4j&lt;/groupId&gt;
&lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
&lt;version&gt;1.6.1&lt;/version&gt;
&lt;type&gt;jar&lt;/type&gt;
&lt;/dependency&gt;
</pre>
<p>Fix your imports in the source file and you are set to use slf4j.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-13.png" alt="" width="636" height="207" /></p>
<p>Now change the reference to &#8220;System.out.println&#8221; with appropriate logging calls.</p>
<pre class="brush: java; title: ; notranslate">

public static void main(String[] args)
{
if(args != null &amp;&amp; args.length &gt; 0)
{
logger.info(new App().sayHello(args[0]));
}else{
logger.warn(&quot;You have to pass atleast one argument to get a warm response from me!&quot;);
}
}
</pre>
<p>Run your main class to ensure that everything is fine.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/Screenshot-14.png" alt="" /></p>
<p>That&#8217;s not we expected. Nothing is logged! There is nothing wrong with this phenomenon as we haven&#8217;t defined any logging provider yet. Remember, slf4j is just a specification.</p>
<p>Okay, it&#8217;s time to add a logging provider and with all the bias let us choose &#8220;logback&#8221; for this purpose. (Please feel free to use your preferred logging provider.)</p>
<p>Slf4j has a bunch of adapters for popular logging frameworks like &#8220;log4j&#8221; and &#8220;jul&#8221; (java.util.logging). (Please don&#8217;t raise flame wars by asking whether &#8220;jul&#8221; is really popular!)</p>
<p>If log4j is your cup of tea or coffee, please go ahead and check the slf4j manuals for further reference. <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I&#8217;ll use &#8220;logback&#8221; for this example and let us add the dependencies for that now. Right click the &#8220;Libraries&#8221; node of your project and click &#8220;Add Dependency&#8221;.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-15.png" alt="" width="454" height="318" /></p>
<p>The IDE should popup a window now where you can search the dependencies you want to add by typing the respective name in the &#8220;Query&#8221; field.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-16.png" alt="" width="516" height="553" /></p>
<p>To use logback in your project, you need to add the dependency &#8220;logback-classic&#8221;. (This will automatically add the transitive dependency &#8220;logback-core&#8221;)</p>
<p>Expand the respective node, choose the version you want and click &#8220;OK&#8221; to add them to the project.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-17.png" alt="" width="516" height="553" /></p>
<p>You can see the added dependencies in the &#8220;Libraries&#8221; node of the project.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-18.png" alt="" width="266" height="285" /></p>
<p>Again, if you are not a big fan of wizards, you can drop in the following snippet in the pom.xml straight away.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;dependency&gt;
&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
&lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
&lt;version&gt;0.9.24&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>That&#8217;s it. If you run the main class now, the logging calls should be negotiated properly.</p>
<p><img src="http://solitarygeek.com/blog/wp-content/uploads/2010/09/screenshot-20.png" alt="" /></p>
<p>To remove a dependency, you can either right click the respective dependency in the &#8220;Libraries&#8221; node and then click &#8220;Remove dependency&#8221; or edit your pom.xml and delete the respective reference to the dependency. It&#8217;s upto you.</p>
<p>To keep this post live up to it&#8217;s title, I&#8217;ll not discuss the tons of other Maven related stuffs NetBeans has. I&#8217;ll probably cover some of them in a later post.</p>
<p>For the sake of completeness, here is the final pom.xml:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;

&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;examples.maven&lt;/groupId&gt;
&lt;artifactId&gt;hellomaven&lt;/artifactId&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;name&gt;hellomaven&lt;/name&gt;
&lt;url&gt;http://maven.apache.org&lt;/url&gt;

&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;junit&lt;/groupId&gt;
&lt;artifactId&gt;junit&lt;/artifactId&gt;
&lt;version&gt;4.8.1&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
&lt;groupId&gt;org.slf4j&lt;/groupId&gt;
&lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
&lt;version&gt;1.6.1&lt;/version&gt;
&lt;type&gt;jar&lt;/type&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
&lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
&lt;version&gt;0.9.24&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;source&gt;1.6&lt;/source&gt;
&lt;target&gt;1.6&lt;/target&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;

&lt;/project&gt;
</pre>
<p>And the java source file:</p>
<pre class="brush: java; title: ; notranslate">

package examples.maven.hellomaven;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Hello world!
*
*/
public class App
{
private static final Logger logger = LoggerFactory.getLogger(App.class);

public static void main(String[] args)
{
if(args != null &amp;&amp; args.length &gt; 0)
{
logger.info(new App().sayHello(args[0]));
}else{
logger.warn(&quot;You have to pass atleast one argument to get a warm response from me!&quot;);
}
}

protected String sayHello(String input)
{
String output = &quot;Hello &quot; + input;
return output;
}
}
</pre>
<p>The Junit test class:</p>
<pre class="brush: java; title: ; notranslate">
package examples.maven.hellomaven;

import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author james
 */
public class AppTest
{
 public AppTest()
 {
 }

 @Test
 public void testSayHello()
 {
 App app = new App();
 String input = &quot;Maven&quot;;
 String expected = &quot;Hello &quot; + input;
 String result = app.sayHello(input);
 assertEquals(expected, result);
 }
}
</pre>
<p>As you have seen above, NetBeans offers great support out-of-the-box for  Maven. No plugins required. If you are not a NetBeans user but use  Maven, I recommend you to give it a try. You&#8217;ll not be disappointed.</p>
<p>Thanks for reading patiently and please leave your comments if you have any.</p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/netbeans-and-maven-a-quick-start-guide/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Subversion and NetBeans &#8211; A quick start guide</title>
		<link>http://solitarygeek.com/java/subversion-and-netbeans-a-quick-start-guide</link>
		<comments>http://solitarygeek.com/java/subversion-and-netbeans-a-quick-start-guide#comments</comments>
		<pubDate>Mon, 07 Apr 2008 02:24:10 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://jamesselvakumar.wordpress.com/?p=49</guid>
		<description><![CDATA[<p>Introduction:</p> <p>Subversion is arguably the most popular version control system as of now. No wonder NetBeans has very good support for Subversion. I personally feel that a java developer must be familiar with both these tools. This article shall help you to get started with both these tools.</p> <p>Objectives: </p> <p>- To create a simple java project in NetBeans.</p> <p>- To import the java project into the subversion repository.</p> <p>- To commit the changes made in a java source file.</p> <p>- To view the revision history of a java source file which was changed.</p> <p>- To rollback to the previous <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/subversion-and-netbeans-a-quick-start-guide">Subversion and NetBeans &#8211; A quick start guide</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction:</strong></p>
<p>Subversion is arguably the most popular version control system as of now. No wonder NetBeans has very good support for Subversion. I personally feel that a java developer must be familiar with both these tools. This article shall help you to get started with both these tools.</p>
<p><strong>Objectives: </strong></p>
<p>- To create a simple java project in NetBeans.</p>
<p>- To import the java project into the subversion repository.</p>
<p>- To commit the changes made in a java source file.</p>
<p>- To view the revision history of a java source file which was changed.</p>
<p>- To rollback to the previous revision of the java source file.</p>
<p><span id="more-186"></span><strong>Requirements:</strong></p>
<p>- NetBeans 6.1 Beta or NetBeans 6.0</p>
<p>- Subversion</p>
<p>- TortoiseSVN</p>
<p>- Though not mandatory, but a basic knowledge of subversion concepts.</p>
<p>Note: You can read this <a href="http://www.solitarygeek.com/version-control/extending-subversion-by-using-tortoisesvn/">article</a> to learn how to install/configure Subversion and TortoiseSVN.</p>
<p><strong> Step 1:</strong></p>
<p>Create a new &#8220;Java Application&#8221; project called &#8220;SimpleLogin&#8221;.</p>
<p><img src="http://farm3.static.flickr.com/2285/2354391015_e8070fe6c2.jpg?v=0" alt="" width="320" height="205" /></p>
<p><strong>Step 2:</strong></p>
<p>Create a new JFrame called &#8220;LoginFrame&#8221; under the package &#8220;org.example.simplelogin&#8221; and add the necessary components as shown below.</p>
<p><img src="http://farm4.static.flickr.com/3246/2355221082_2e9b59379e.jpg?v=0" alt="" width="389" height="319" /></p>
<p><strong>Step 3:</strong></p>
<p>Name the swing components accordingly.</p>
<p><img src="http://farm3.static.flickr.com/2092/2354399601_5e9845018a.jpg?v=0" alt="" width="316" height="214" /></p>
<p>Your application should like this now on preview:</p>
<p><img src="http://farm4.static.flickr.com/3224/2354366319_b5dac51760.jpg?v=0" alt="" width="368" height="236" /></p>
<p><strong> Step 4:</strong></p>
<p>Create a java class named &#8220;LoginService&#8221; under the package &#8220;org.example.simplelogin&#8221;.</p>
<p><img src="http://farm3.static.flickr.com/2370/2354421741_398aa583b0.jpg?v=0" alt="" width="209" height="127" /></p>
<p><strong>Step 5:</strong></p>
<p>Add the following code to the LoginService class.</p>
<p><img src="http://farm4.static.flickr.com/3032/2354421803_83e0994905.jpg?v=0" alt="" width="500" height="289" /></p>
<p>Here we are defining a simple method which shall return true if the username is &#8220;guest&#8221; and the password is &#8220;password&#8221;.</p>

<p><strong>Step 6:</strong></p>
<p>Now open &#8220;LoginFrame.java&#8221; and add the following methods.</p>
<p><img src="http://farm3.static.flickr.com/2285/2354439587_93693668f4.jpg?v=0" alt="" width="500" height="379" /></p>
<p>The above methods are self explanatory. We are just doing a simple validation and calling the login method we defined previously in the class LoginService.</p>
<p><strong>Step 7:</strong></p>
<p>Now double click the login &#8220;button&#8221; in the design mode of LoginFrame.java to create the event handling method named &#8220;loginButtonActionPerformed&#8221;. Add the following code to call the &#8220;performLogin&#8221; method.</p>
<p><img src="http://farm4.static.flickr.com/3248/2355269808_59b4391e3f.jpg?v=0" alt="" width="500" height="146" /></p>
<p>That&#8217;s it.</p>
<p><strong>Step 8:</strong></p>
<p>Run the project.</p>
<p>If you enter the username as &#8220;guest&#8221; and password as &#8220;password&#8221;, you will get an output like this.</p>
<p><img src="http://farm4.static.flickr.com/3230/2355196504_9173f89f63.jpg?v=0" alt="" width="392" height="241" /></p>
<p>Otherwise, you will be getting an output like this.</p>
<p><img src="http://farm3.static.flickr.com/2001/2354366847_faebc87abf.jpg?v=0" alt="" width="393" height="242" /></p>
<p>Ok, our simple login application is ready for prime time <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Now let us import this project into a subversion repository.</p>
<p><strong>Step 9:</strong></p>
<p>Create an empty folder called &#8220;MyRepository&#8221; in a preferred location.</p>
<p><img src="http://farm3.static.flickr.com/2158/2332675889_afaca8cb2b.jpg?v=0" alt="" width="390" height="435" /></p>
<p><strong>Step 10:</strong></p>
<p>Create a subversion repository in the empty &#8220;MyRepository&#8221; folder as mentioned below, by right clicking anywhere inside the windows explorer.</p>
<p><img src="http://farm3.static.flickr.com/2240/2333503938_c0cc41b66b.jpg?v=0" alt="" width="376" height="342" /></p>
<p>Accept the default option (FSFS)  in the &#8220;Create Repository&#8221; window.</p>
<p><img src="http://farm4.static.flickr.com/3039/2332675945_2ef1cf39a5.jpg?v=0" alt="" width="285" height="178" /></p>
<p>That&#8217;s it. Your repository should be ready when you press &#8220;OK&#8221; and it should look something like this.</p>
<p><img src="http://farm4.static.flickr.com/3136/2333503978_2f67050339.jpg?v=0" alt="" width="367" height="276" /></p>
<p><strong>Step 11:</strong></p>
<p>Let us import the NetBeans project we have created into the subversion repository. Right click the NetBeans project we have created and then click &#8220;Versioning -&gt; Import into Subversion Repository&#8221;.</p>
<p><img src="http://farm4.static.flickr.com/3227/2354370051_a1bb1babc9.jpg?v=0" alt="" width="450" height="500" /></p>
<p>NetBeans will prompt you with a window. Enter the path of your repository as shown below.</p>
<p><img src="http://farm4.static.flickr.com/3131/2354366929_c0b9e131fc.jpg?v=0" alt="" width="500" height="363" /></p>
<p>Click the &#8220;Next&#8221; button and enter the &#8220;Repository Folder&#8221; name into which you would like to import your project. To make things simple, let us enter our NetBeans project name itself as the &#8220;Repository Folder&#8221; name. Also enter a small description about this import activity as shown below.<br />
<img src="http://farm4.static.flickr.com/3190/2354367351_3b774a4fe0.jpg?v=0" alt="" width="500" height="363" /></p>
<p>We are almost there. Click the &#8220;Next&#8221; button and the IDE will show a window like this.</p>
<p><img src="http://farm3.static.flickr.com/2360/2354367443_e95904ec06.jpg?v=0" alt="" width="500" height="363" /></p>
<p>Accept the default entries and click &#8220;Finish&#8221;. Congratulations! you have imported your project successfully into the subversion repository.</p>
<p>Right click anywhere in your desktop/windows explorer and click &#8220;TortoiseSVN -&gt; Repo-Browser&#8221; and then enter the path of your subversion repository. You can see all your project files sitting comfortably inside the subversion repository. <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><img src="http://farm3.static.flickr.com/2380/2354367493_f3d0a11d7e.jpg?v=0" alt="" width="500" height="385" /></p>
<p><strong>Step 12:</strong></p>
<p>Let us play around with some more cool subversion integration features offered by NetBeans. Open the class &#8220;LoginService.java&#8221; and change the value of &#8220;DUMMY_PASSWORD&#8221; from &#8220;password&#8221; to &#8220;guest&#8221;.</p>
<p><img src="http://farm3.static.flickr.com/2279/2354367625_3451f147bb.jpg?v=0" alt="" width="488" height="132" /></p>
<p>You can see the IDE markup a blue shade near the line you made the change. This indicates that your source file has got something different than the version in the repository. You can also note that the IDE change your java source file name&#8217;s font-color to blue.</p>
<p><img src="http://farm3.static.flickr.com/2100/2355197270_23d115a77c.jpg?v=0" alt="" width="211" height="169" /></p>
<p>Let us turn our focus to the editor window again. Click the blue stripe shown by the IDE near the  place where you made changes to the source file. The IDE will popup a small hint-window.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2306/2355199812_f99bab7f3d.jpg?v=0" alt="screenshot" /></p>
<p>You can see the previous value of the DUMMY_PASSWORD there. The IDE also provides you a set of buttons to revert back the changes or to have a &#8220;diff&#8221; view on the changes made. Let us explore the &#8220;diff&#8217; functionality of the IDE first by clicking the &#8220;diff&#8221; button.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2087/2354370155_6d7e54a8b8.jpg?v=0" alt="screenshot" /></p>
<p>The IDE will display the &#8220;diff&#8221; view of the &#8220;working copy&#8221; and the &#8220;HEAD&#8221; revision (the latest committed version) in the repository.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2345/2355198438_3bd7fbf264.jpg?v=0" alt="screenshot" /></p>
<p>From the above figure, you can see the current and previous value of the string DUMMY_PASSWORD. Now you can revert back to the old value of &#8220;DUMMY_PASSWORD&#8221; by clicking the replace  button (displayed like an arrow)</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2351/2354368671_662f937baa.jpg?v=0" alt="screenshot" /></p>
<p>When you press the &#8220;replace&#8221; button, the IDE will replace the &#8220;current&#8221; value with the &#8220;original&#8221; value.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2190/2354369007_61c4845791.jpg?v=0" alt="screenshot" /></p>
<p>The &#8220;diff&#8221; view provided by the IDE will be very useful to examine and compare the changes made to the &#8220;working copy&#8221;  alongwith the option to revert back to the original version in the repository. But if all you need is to quickly revert back some change to the original version in the repository, you can click on the blue strip in the source code and click the &#8220;revert&#8221; button.</p>
<p><img class="alignnone" src="http://farm4.static.flickr.com/3166/2354370183_f78490efc2.jpg?v=0" alt="screenshot" /></p>
<p>That&#8217;s cool, right?</p>
<p><strong>Step 13:</strong></p>
<p>Enough playing. Now let us commit the changes we made in our source file. Ensure that the source file you are willing to commit is in focus and click the menu &#8220;Versioning -&gt; Commit&#8221;</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2172/2354369307_0be03de170.jpg?v=0" alt="screenshot" /></p>
<p>When you click the &#8220;Commit&#8221; menu item, the IDE will prompt you with a window to enter the &#8220;message&#8221; for this commit operation. Enter a commit message and click the &#8220;Commit&#8221; button.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2318/2355199090_2c2ae15907.jpg?v=0" alt="screenshot" /></p>
<p><strong>Step 14:</strong></p>
<p>Let us explore the history of our source file and see the the changes we made all along. Click the &#8220;Versioning -&gt; Search History&#8221; menu.</p>
<p><img class="alignnone" src="http://farm3.static.flickr.com/2069/2354369489_750d96fbe5.jpg?v=0" alt="screenshot" /></p>
<p>The IDE will display all the versions of the source file.</p>
<p><img class="alignnone" src="http://farm4.static.flickr.com/3114/2355199460_9c845473d6.jpg?v=0" alt="screenshot" /></p>
<p>In the &#8220;Search History&#8221; window, the IDE offers two views, &#8220;summary&#8221; view and &#8220;diff&#8221; view. By default, the IDE displays the &#8220;summary&#8221; view. The &#8220;diff&#8221; view contains more information.</p>
<p><img class="alignnone" src="http://farm4.static.flickr.com/3179/2354369639_4956351bea.jpg?v=0" alt="screenshot" /></p>
<p>You can straightaway &#8220;revert&#8221; or &#8220;rollback&#8221; to previous revisions just by right clicking a particular revision.</p>
<p><img class="alignnone" src="http://farm4.static.flickr.com/3274/2354370017_5f7832e150.jpg?v=0" alt="screenshot" /></p>
<p>Nice, isn&#8217;t it? There are still a lot more cool subversion features offered by NetBeans. I will blog more about that later. I hope the information provided here was useful to you.</p>
<p>Read also: &#8220;<a href="http://solitarygeek.com/java/netbeans-and-maven-a-quick-start-guide">NetBeans and Maven &#8211; A quick start guide</a>&#8221;</p>
<p><strong>SolitaryGeek Poll</strong></p>
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/subversion-and-netbeans-a-quick-start-guide/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Extending Subversion by using TortoiseSVN</title>
		<link>http://solitarygeek.com/version-control/extending-subversion-by-using-tortoisesvn</link>
		<comments>http://solitarygeek.com/version-control/extending-subversion-by-using-tortoisesvn#comments</comments>
		<pubDate>Fri, 14 Mar 2008 09:56:22 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tortoisesvn]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jamesselvakumar.wordpress.com/?p=45</guid>
		<description><![CDATA[<p>Though Subversion is a powerful version control system, it&#8217;s command-line based interface may not appeal to some users who used other version control systems like Visual Source Safe. And what if you want to remotely access your repository as well?</p> <p>TortoiseSVN and Apache comes to your aid. TortoiseSVN is a powerful tool for Subversion, which helps you to issue most of the subversion commands from your windows explorer. Subversion has an inbuilt &#8220;svnserve&#8221; utility which helps you to expose your repository to remote users, but it&#8217;s highly recommended to use the flexible Apache Web Server for this purpose. Subversion comes <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/version-control/extending-subversion-by-using-tortoisesvn">Extending Subversion by using TortoiseSVN</a></span>]]></description>
			<content:encoded><![CDATA[<p>Though <a href="http://subversion.tigris.org/">Subversion</a> is a powerful version control system, it&#8217;s command-line based interface may not appeal to some users who used other version control systems like Visual Source Safe. And what if you want to remotely access your repository as well?</p>
<p><a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a> and <a href="http://httpd.apache.org/">Apache</a> comes to your aid. TortoiseSVN is a powerful tool for Subversion, which helps you to issue most of the subversion commands from your windows explorer. Subversion has an inbuilt &#8220;svnserve&#8221; utility which helps you to expose your repository to remote users, but it&#8217;s highly recommended to use the flexible Apache Web Server for this purpose. Subversion comes with it&#8217;s own apache modules to expose your repository to remote users. However, in this article we will not focus on Apache. I&#8217;m planning to write about the apache integration in my next post. Please be patient <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Objective:</strong></p>
<p>In this article you will learn how to install Subversion and TortoiseSVN and use them to create a repository, import files into the repository and view the repository.</p>
<p><span id="more-182"></span><strong>Step 1: Install Subversion</strong></p>
<p>Download <a href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100&amp;expandFolder=8100&amp;folderID=8100">subversion windows installer</a> for Apache 2.2.x. (Download the file called &#8220;svn-x.y.z-setup.exe&#8221; and run the installer. Installing should be a straight forward option.</p>
<p>You might see the following windows. They are self explanatory.</p>
<p><img src="http://farm3.static.flickr.com/2015/2332581729_722229490c.jpg?v=0" alt="subversion-1" width="500" height="390" /></p>
<p><img src="http://farm3.static.flickr.com/2194/2332581779_89f2489ba9.jpg?v=0" alt="" width="500" height="389" /></p>
<p><img src="http://farm4.static.flickr.com/3157/2333409118_3e44bf4620.jpg?v=0" alt="" width="500" height="390" /></p>
<p><img src="http://farm4.static.flickr.com/3031/2332581753_bb6aa20a34.jpg?v=0" alt="" width="500" height="390" /></p>
<p><img src="http://farm4.static.flickr.com/3087/2333409144_39020eda8b.jpg?v=0" alt="" width="500" height="391" /></p>
<p><img src="http://farm4.static.flickr.com/3062/2332581683_75f1cdabe2.jpg?v=0" alt="" /></p>
<p>Now you should have subversion successfully installed in your machine. To verify that, open the command prompt and type &#8220;svn &#8211;version&#8221;. If you see something like below, pat your head, you have successfully installed subversion.</p>
<p><img src="http://farm3.static.flickr.com/2103/2333443034_ca6f6b02f7.jpg?v=0" alt="" width="500" height="253" /></p>
<p>If you couldn&#8217;t see the above mentioned message, you might want to check your &#8220;Path&#8221; environment variable and add your subversion installation directory to the &#8220;Path&#8221;.</p>
<p><strong> Step 2: Install TortoisSVN</strong></p>
<p>Download TortoiseSVN from <a href="http://tortoisesvn.net/downloads">here.<img src="http://farm3.static.flickr.com/2329/2332648723_37092443ac.jpg?v=0" alt="" /></a></p>
<p><img src="http://farm3.static.flickr.com/2308/2332648747_5e44fd2c99.jpg?v=0" alt="" /></p>
<p><img src="http://farm4.static.flickr.com/3079/2332648767_7e4533a861.jpg?v=0" alt="" /></p>
<p><img src="http://farm4.static.flickr.com/3034/2332648795_7f266f1ba9.jpg?v=0" alt="" width="499" height="392" /></p>
<p>That&#8217;s it. Now the installer setup might prompt you to restart your system to complete the installation process. Accept it.</p>
<p><strong>Step 3: Create a Subversion Repository</strong></p>
<p>Now, it&#8217;s time to create a subversion repository. Though it&#8217;s possible to use the subversion&#8217;s &#8220;svnadmin&#8221; command to create the repository, we will use TortoiseSVN to achieve that.</p>
<p><em>3a)</em> First, choose a appropriate location to keep all your repositories. In my case it&#8217;s &#8220;F:\Subversion&#8221;. Let us call this folder as REPOSITORY_ROOT. Now, let us create an empty directory called  &#8220;MyRepository&#8221; inside REPOSITORY_ROOT. It should look something like this:</p>
<p><img src="http://farm3.static.flickr.com/2158/2332675889_afaca8cb2b.jpg?v=0" alt="" width="390" height="435" /></p>
<p><em>3b) </em>Now, right click inside the  folder REPOSITORY_ROOT\MyRepository, and click &#8220;TortoiseSVN -&gt; Create repository here&#8221; menu.</p>
<p><img src="http://farm3.static.flickr.com/2240/2333503938_c0cc41b66b.jpg?v=0" alt="" width="376" height="342" /></p>
<p><em> 3c) </em>TortoisSVN will now prompt you with a message box like this:</p>
<p><img src="http://farm4.static.flickr.com/3039/2332675945_2ef1cf39a5.jpg?v=0" alt="" width="285" height="178" /></p>
<p>Leave the default option (Native file system), and click &#8220;OK&#8221;.  You can see a bunch of files inside the &#8220;MyRepository&#8221; folder like this:</p>
<p><img src="http://farm4.static.flickr.com/3136/2333503978_2f67050339.jpg?v=0" alt="" width="367" height="276" /></p>
<p>Great!! This is your subversion repository.</p>
<p><strong>Step 4: Import files into your subversion repository</strong></p>
<p><em>4a)</em> Let us add some files inside our newly created subversion repository. Right click a folder of your choice and click &#8220;TortoiseSVN -&gt; Import&#8221;</p>
<p><img src="http://farm3.static.flickr.com/2196/2333543634_3a70408d79.jpg?v=0" alt="" width="468" height="287" /></p>
<p><em> 4b)</em> Enter the appropriate repository path where you would like to import these files into. In my case it&#8217;s &#8220;file:///f:/subversion/myrepository/photos&#8221;.</p>
<p><img src="http://farm3.static.flickr.com/2286/2333543664_678e9ef0b7.jpg?v=0" alt="" width="458" height="343" /></p>
<p><em>4C)</em> When you press &#8220;OK&#8221;, TortoiseSVN will import all the files/folders inside the folder which you selected for the import operation into the subversion  repository.</p>
<p><img src="http://farm4.static.flickr.com/3140/2332714865_7a3bbed878.jpg?v=0" alt="" width="500" height="273" /></p>
<p><em>4D)</em> Press &#8220;OK&#8221;. Now we have finished importing the files into our new subversion repostiory. It&#8217;s now time to view the content of our repository.</p>
<p><strong> Step 5: Viewing the content of your subversion repository</strong></p>
<p><em>5a)</em> TortoiseSVN provides a nice &#8220;Repository Browser&#8221; option to view the content of your subversion repository. Right anywhere in your explorer window/desktop and click &#8220;TortoiseSVN -&gt; Repo-browser&#8221;.</p>
<p><img src="http://farm4.static.flickr.com/3036/2332741151_2f1480667a.jpg?v=0" alt="" width="392" height="356" /></p>
<p><em>5B)</em> Enter the url of your subversion repository. In my case, it&#8217;s &#8220;file:///f:/subversion/myrepository&#8221; and click &#8220;OK&#8221;.</p>
<p><img src="http://farm4.static.flickr.com/3064/2332741171_72e3734e8c.jpg?v=0" alt="" width="357" height="118" /></p>
<p><em> 5C)</em> That&#8217;s it, now TortoiseSVN will list down all the files inside your repository.</p>
<p><img src="http://farm3.static.flickr.com/2028/2332741223_afcd4bbab3.jpg?v=0" alt="" width="500" height="386" /></p>
<p><strong>Summary</strong>:</p>
<p>In this article, you learned to:</p>
<p>- install Subversion</p>
<p>- install TortoiseSVN</p>
<p>- create a new repository using TortoiseSVN</p>
<p>- import files into the subversion repository using TortoiseSVN</p>
<p>- view the content of the subversion repository using TortoiseSVN</p>
<p><strong>What next?</strong></p>
<p>I initially thought of even writing about installing, configuring apache/websvn in this article itself. But it already took me nearly 3 hours to finish writing this. So please bear with me. I&#8217;ll come with a Part II of this article where you will learn how to use apache/websvn along with subversion to make the interaction with your version control system a pleasure. See you again.</p>
<p><em>Added on August 2, 2008:</em></p>
<p>I have written an article named &#8220;<a href="http://jamesselvakumar.wordpress.com/2008/08/01/extending-subversion-with-apache/">Extending Subversion with Apache</a>&#8220;. This article is about setting up Apache http server and configuring it to access subversion repositories. It also deals how to setup Authentication and Access control for your subversion repositories using Apache. Hope you find it useful.</p>
<p><strong>SolitaryGeek Poll</strong></p>
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/version-control/extending-subversion-by-using-tortoisesvn/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

