Using Eclipse

From VuzeWiki
Jump to: navigation, search

This page gives a step by step description of running the Vuze/Azureus BitTorrent client in the Eclipse IDE. This has been tested with Vuze source code and Eclipse 3.7 (Indigo).

Note: If you're familiar with Eclipse and want to do everything your own way the Project and Run chapters will be interesting for you

Note: This article was almost completely rewritten in April 2010 to reflect the change to the SVN source code repository (from the old CVS).

Installing Eclipse[edit]

  1. Download Eclipse and extract the archive to a directory of your choice
  2. Start the Eclipse launcher (the actual file name depends on the OS) and choose a location for the workspace (the default path should be ok)
  3. Under Window > Preferences, tweak the following settings:
    • Java > Build Path: select Folders and clear the source folder box and make sure "bin" is in the output folder box.
  4. click on OK and go to the Project Menu and unselect Build Automatically (Eclipse will build the project anyway when you use the Run option)

Set up SVN Functionality[edit]

To load Vuze into Eclipse for editing, the first thing you should do is set up SVN client functionality. That can be be done easiest by installing Subclipse. Subclipse will add SVN functionality to Eclipse. It can be installed through Eclipse's update system.

  • When installing Subclipse, make sure that you are running Eclipse with Admin rights. Subclipse plugin will not work, if you install it to your Eclipse profile directory. It needs to be in Eclipse's global plugin directory. Especially if you are running Windows Vista or Windows 7, make sure that during the install you run Eclipse with "Run as administrator" and the plugin gets installed into glocal plugin directory. (If you run Eclipse normally, the plugin ends up to your personal Eclipse plugin directory.) Same advice for Linux. See here:
Possible locations for org.tigris.subversion.subclipse.ui_1.6.17.jar and other plugin components:
  • Wrong place: C:\Users\<username>\.eclipse\org.eclipse.platform_3.6.1_920333535\plugins
  • Correct place: C:\Program Files\Eclipse\plugins
This is tricky. I have now twice been burned with the issue with Eclipse updates, and it always takes some time to figure it out...

That way you can easily get the latest code.

SVN Subversion 1.7[edit]

Please note that Subversion 1.7 has a different storage format for working copies than the earlier 1.0-1.6 versions. An 1.7 client can't operate 1.6 working copies, and an 1.6 client does not understand 1.7 copies. The 1.6 working copies can be converted to 1.7 format with the 1.7 client. (The server side is still compatible.) If you use several SVN clients (like Subclipse in Eclipse and TortoiseSVN generally in Windows), make sure that you update all your SVN clients at the same time.

Subclipse SVN 1.7 for Eclipse can be found by defining the installation site in Eclipse (instead of the update_1.6.x).

Import Vuze source code[edit]

Lets walk through the steps in getting the actual source code.

  • Note (unconfirmed information): If you are using Windows7, disable indexing, because it causes error (file cannot be accessed)
  1. Open up the SVN Repository perspective in Eclipse. You can do that by going to Window > Open Perspective > SVN Repository Exploring. If the SVN Repositories view is not showing, click on Window > Show View > SVN Repositories.
  2. Right click in the SVN perspective, and choose New > Repository Location. You will be presented with the Add a new SVN Repository dialog. There is only one field you need to fill in:
  3. When the repository is shown in the view, select Checkout... from the context menu.
  4. Select Check out as a project using the New Project Wizard, (make sure that you are checking out the HEAD revision and Depth is fully recursive) and click on Finish
  5. In the New project popup window select Java > Java Project, continue
  6. Enter a Project name, i.e. "AZ-SVN" and select create new project in workspace and create separate source and output folders (the .class files will be placed in a different output folder instead in the same folders as the sourcecode)
  7. Finish the wizard by accepting defaults in Java settings. If you set the global output folder option properly, the wizard should suggest now the /bin subdirectory as output folder.

When the download of the sources is completed you can change to the Java Perspective (Window > Open Perspective > Java), adding the Navigator view could be useful to explore the project's file structure. Eclipse might also do that automatically.

Configure the Project[edit]

Vuze structure of having the source code in three separate trees makes things a bit challenging, and you need to change the Java build path a bit.

Once you're in the java perspective you should do the following things:

  1. Go to the Navigator tab
  2. Right-click on the project > Properties > Java Build Path
  3. Go to the Source tab, and
    • Remove the default inclusion of all project sources (e.g. AZ-SVN).
    • Add the three proper source tree folders: /azureus2/src/, /azureus3/src/ and /uis/src/
    • Also check the output folder stated on the bottom is "project_name/bin"
    SVN project JavaBuildPath.png
  4. Then go to Libraries tab, and select Add JARs..., select all .jar libraries from your project trees /azureus2/lib/ and /uis/lib/. Add all those selected .jar files by selecting Ok. (Note: the library AppleJavaExtensions.jar was removed in May 2010 in version
    (Note, unconfirmed info: xosx.jar causes error in windows systems, dont include that.)
  1. SVN AddLibrary1.png
    Now you should have those libraries there.
    SVN AddLibrary2.png
  2. Save everything by selecting Ok.

Eclipse should be able to compile your project now, you can manually start a build process via Right-click > Build Project'

Configure the Run dialog[edit]

  1. Go to the Navigator tab
  2. Right-click on the project > Run configurations
  3. Select Java application, click on New and give it a name (i.e. the same as the project name)
  4. On the "Main" tab,
    • Select the correct project manually or using Browse
    • Put "org.gudy.azureus2.ui.swt.Main" into the Main class box.
    SVN RunConfigMain.png
  5. Go to the Arguments tab and deselect the Default checkbox on the bottom and put the path of your installed Azureus version in Other as the working directory if you want to reuse the installed plugins and/or sub-directories created by plugins. This enables you to use your existing Vuze configuration & environment. The correct working directory for the mac is /Applications.
  6. Mac only: put -XstartOnFirstThread into VM arguments field.
    SVN RunConfigArguments.png
    • Note: If you don't have a pre-built version of Azureus you'll need to download the swt-libs for your OS from the Eclipse website and put them into the specified working directory. It might be a good idea to create the working directory outside the workspace since the core plugins will be installed in it.
  7. Go to the Classpath tab and add the swt.jar from your installed Azureus version/working directory through Add External JARs... to the User Entries. (If you are building this using 64-bit Eclipse your Vuze installation also needs to be 64-bit. It probably isn't, or at least you have both 32bit and 64bit Javas. Regarding running Vuze, the tricky part is having both 32bit and 64bit swt.jars coexist side by side. One solution is to have swt.jar for your default java architecture, and then renamed copies e.g. swwt32.jar and swwt64.jar, so that you can point Eclipse to use the correct one.)
    SVN RunConfigClasspath.png
  8. Go to the Environment tab and add Variable LD_LIBRARY_PATH with the Value of your output folder (/bin subdirectory to the project, if you followed the previous advice).
    SVN RunConfigEnvironment.png
  9. Save settings with Apply and finally select Run.

Building an Azureus2.jar[edit]

  1. Go to the Navigator tab
  2. If you haven't built the project yet: Right-click on the project > Build Project
  3. Right-click on the project > Export...
  4. Go to the export tab and select Java > JAR file.
  5. In the next step:
    • Select your Project in the Select resources to export field
    • Only this checkbox hould be checked: Export all output folders for checked projects
    • Select the output folder (=export destination) for your Azureus2.jar, i.e. inside the workspace or your azureus program/working directory (see #Configure the Run dialog). Note that you can also give another name to the .jar file to generated.
    • Enable these options: compress the contents of the jar file and add directory entries
  6. If you have to build .jar files frequently you can go to the next page and overwrite the Azureus2.jardesc in your project root folder
    To rebuild the .jar file Right-click on the Azureus2.jarfile in the Package Explorer and select Create jar
  7. Go to the last page and add org.gudy.azureus2.ui.swt.Main as main class. (You can use the Browse button and then write main to find the class easily)
  8. Finish the dialog and wait until the .jar file is build

Synchronizing with the SVN repository[edit]

  1. Go to the Navigator tab (or any other tab showing Team in context menu)
  2. Right-click on the project > Team > Update to HEAD (it may change to the Team sychnoronize perspective now or open the Synchronize tab)
    • Should you want to update to a certain older version, you can select Update to Version....

Old CVS related:

  1. Wait until Eclipse has found all differences
  2. Click on the Incoming Mode button if you want to see what has changed
  3. Click on the Update all incoming changes... button to update
  4. In case you have modified files and the same files have been changed in the CVS too continue with the following steps:
  5. Click on the Conflicts Mode button
  6. Double-click on the conflicting file(s) to open the Compare Editor
  7. Now you can what differs on both sides, since you don't have CVS write access you can only import incoming changes, either do that manually by clicking on the square in the middle bar for each incoming change or simply click on the Copy all non-conflicting changes from the right to the left button, of course that only works for differences on that don't conflict with your own changes. If there are such differences you have to rewrite your code manually.
  8. after you have imported the changes from CVS or modified your own code in a way that matches the CVS changes right-click on the file in the Synchronize tab and select Mark as Merged