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.
- To create a simple java project in NetBeans.
- To import the java project into the subversion repository.
- To commit the changes made in a java source file.
- To view the revision history of a java source file which was changed.
- To rollback to the previous revision of the java source file.
- NetBeans 6.1
- Subversion
- TortoiseSVN
- Though not mandatory, but a basic knowledge of subversion concepts.
Create a new "Java Application" project called "SimpleLogin".
![]() |
Create a new JFrame called "LoginFrame" under the package "org.example.simplelogin" and add the necessary components as shown below.
![]() |
Name the swing components accordingly.
![]() |
Your application should like this now on preview:
![]() |
Create a java class named "LoginService" under the package "org.example.simplelogin".
![]() |
Add the following code to the LoginService class.
![]() |
Here we are defining a simple method which shall return true if the username is "guest" and the password is "password".
Now open "LoginFrame.java" and add the following methods.
![]() |
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.
Now double click the login "button" in the design mode of LoginFrame.java to create the event handling method named "loginButtonActionPerformed". Add the following code to call the "performLogin" method.
![]() |
That's it.
Run the project.
If you enter the username as "guest" and password as "password", you will get an output like this.
![]() |
Otherwise, you will be getting an output like this.
![]() |
Ok, our simple login application is ready for prime time :-). Now let us import this project into a subversion repository.
Create an empty folder called "MyRepository" in a preferred location.
![]() |
Create a subversion repository in the empty "MyRepository" folder as mentioned below, by right clicking anywhere inside the windows explorer.
![]() |
Accept the default option (FSFS) in the "Create Repository" window.
![]() |
That's it. Your repository should be ready when you press "OK" and it should look something like this.
![]() |
Let us import the NetBeans project we have created into the subversion repository. Right click the NetBeans project we have created and then click "Versioning -> Import into Subversion Repository".
![]() |
NetBeans will prompt you with a window. Enter the path of your repository as shown below.
![]() |
Click the "Next" button and enter the "Repository Folder" name into which you would like to import your project. To make things simple, let us enter our NetBeans project name itself as the "Repository Folder" name. Also enter a small description about this import activity as shown below.
![]() |
We are almost there. Click the "Next" button and the IDE will show a window like this.
![]() |
Accept the default entries and click "Finish". Congratulations! you have imported your project successfully into the subversion repository.
Right click anywhere in your desktop/windows explorer and click "TortoiseSVN -> Repo-Browser" and then enter the path of your subversion repository. You can see all your project files sitting comfortably inside the subversion repository. :-)
![]() |
Let us play around with some more cool subversion integration features offered by NetBeans. Open the class "LoginService.java" and change the value of "DUMMY_PASSWORD" from "password" to "guest".
![]() |
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's font-color to blue.
![]() |
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.
![]() |
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 "diff" view on the changes made. Let us explore the "diff' functionality of the IDE first by clicking the "diff" button.
![]() |
The IDE will display the "diff" view of the "working copy" and the "HEAD" revision (the latest committed version) in the repository.
![]() |
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 "DUMMY_PASSWORD" by clicking the replace button (displayed like an arrow)
![]() |
When you press the "replace" button, the IDE will replace the "current" value with the "original" value.
![]() |
The "diff" view provided by the IDE will be very useful to examine and compare the changes made to the "working copy" 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 "revert" button.
![]() |
That's cool, right?
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 "Versioning -> Commit"
![]() |
When you click the "Commit" menu item, the IDE will prompt you with a window to enter the "message" for this commit operation. Enter a commit message and click the "Commit" button.
![]() |
Let us explore the history of our source file and see the the changes we made all along. Click the "Versioning -> Search History" menu.
![]() |
The IDE will display all the versions of the source file.
![]() |
In the "Search History" window, the IDE offers two views, "summary" view and "diff" view. By default, the IDE displays the "summary" view. The "diff" view contains more information.
![]() |
You can straightaway "revert" or "rollback" to previous revisions just by right clicking a particular revision.
![]() |
| Figure1.jpg | ![]() |
41633 bytes |
| Figure10.jpg | ![]() |
30137 bytes |
| Figure11.jpg | ![]() |
70908 bytes |
| Figure12.jpg | ![]() |
36816 bytes |
| Figure13.jpg | ![]() |
29340 bytes |
| Figure14.jpg | ![]() |
57129 bytes |
| Figure15.jpg | ![]() |
66626 bytes |
| Figure16.jpg | ![]() |
44281 bytes |
| Figure17.jpg | ![]() |
49303 bytes |
| Figure18.jpg | ![]() |
90659 bytes |
| Figure19.jpg | ![]() |
73551 bytes |
| Figure2.jpg | ![]() |
38064 bytes |
| Figure20.jpg | ![]() |
34736 bytes |
| Figure21.jpg | ![]() |
21878 bytes |
| Figure22.jpg | ![]() |
46606 bytes |
| Figure23.jpg | ![]() |
43107 bytes |
| Figure24.jpg | ![]() |
64220 bytes |
| Figure25.jpg | ![]() |
62144 bytes |
| Figure26.jpg | ![]() |
55797 bytes |
| Figure27.jpg | ![]() |
44338 bytes |
| Figure28.jpg | ![]() |
64329 bytes |
| Figure29.jpg | ![]() |
54452 bytes |
| Figure3.jpg | ![]() |
29005 bytes |
| Figure30.jpg | ![]() |
62418 bytes |
| Figure31.jpg | ![]() |
51737 bytes |
| Figure32.jpg | ![]() |
75180 bytes |
| Figure33.jpg | ![]() |
81139 bytes |
| Figure4.jpg | ![]() |
23393 bytes |
| Figure5.jpg | ![]() |
16514 bytes |
| Figure6.jpg | ![]() |
46406 bytes |
| Figure7.jpg | ![]() |
69662 bytes |
| Figure8.jpg | ![]() |
20923 bytes |
| Figure9.jpg | ![]() |
28905 bytes |