Convert VB6 to Java with Jump2Java – A step-by-step guide

Download Jump2Java

1.Jump 2 Java is an integrated development environment (IDE) for converting VB6 (Visual Basic 3-6) projects to Java Server Faces (JSF) or Java Swing applications. It is implemented as a plugin to Eclipse to enable it to be used in direct conjunction with all your other favourite Java development tools. You install the Jump 2 Java IDE by registering an account and thereby receive a link to a download site. You copy and paste the link into Eclipse and follow the instructions in the installation wizard. The image to your right shows the major steps in the installation.

Watch how to download and install jump2java in Eclipse.

Create VB6 Conversion Project

2.Once the IDE is installed you should be able to create a VB6 conversion project from the project explorer by right-clicking and following the option ‘New->Project…’. You need to supply the following information: the location of the Visual Basic project file (.vbp or .vbg) containing information about the application to migrate, a name for your new VB6 conversion project in Eclipse, a name of the Java project in Eclipse that will contain the resulting converted code and which platform, i.e., JSF or Swing, that you would like to convert to. You supply this information and choose to create a project.

Watch how to create the project.

Inspect VB6 conversion project structure

3.Two Eclipse projects are now created: the ‘source’ and the ‘target’ project. The ‘source’ project contains the visual basic (VB6) source code to be converted and the ‘target’ project will contain the resulting converted java code.

The source project contains three top-level directories: ‘migration source’, ‘reports’ and ‘licence’. The ‘migration source’ directory contains your visual basic source code. The visual basic files are not moved from their original location; they are linked symbolically to the conversion project directory structure. However, the files are shown and are editable in the IDE in an editor with syntax high-lighting for Visual Basic 6. You can work with your source code directly from the IDE and simultaneously continue the development in Visual Studio. The ‘reports’ directory contains any reports produced during the conversion run and the ‘license’ directory will hold your purchased license for this specific application (see below). The image to your right shows a picture of the structure and the syntax high-lightning of the visual basic source code.

Run Application Analysis of the VB6 Code to be converted

4.Now it’s time to start working! A full source code analysis is performed by right-clicking on the VB6 conversion project and choosing ‘Jump 2 Java > Perform project and application analysis’. All issues found in the analysis are added as tasks in the Eclipse task list. Each task describes the issue and by clicking the task, the exact location in the source code is high-lighted.

Basically there are three types of issues: ‘undefined system type’, ‘unsupported API function’ and ‘undefined gui control’. An ‘undefined system type’ or ‘unsupported API function’ issue means that the visual basic source code is using an external library (or windows API call), which source code you do not have access to, and, hence, cannot be converted. The compiler will automatically handle these issues by generating a proxy class for the library and populating the class with the method signatures used in the converted source. After compilation, these proxies are then to be implemented in Java. An ‘undefined GUI control’ issue high-lights any GUI controls which do not have an equivalent counterpart in JSF or Swing and hence needs to be handled manually after compilation. The compiler maps standard controls from visual basic that do have a standard GUI component in the target language and platform.

Moreover, the analysis step also creates a high-level report including key metrics about the source application, such as source lines of code counts, conversion precision, number of unsupported controls, etc. The report is located in the ‘reports’ directory of your project.

Highlighting these external dependencies and key metrics at this early stage in the process is a great source for project planning. Read more about running a conversion project in this article.

Watch how to run the project and application analysis.

Request a project licence for the VB6 conversion to Java

5.You are now ready to perform the conversion of your source code. You start this process by requesting and purchasing an application-unique license, using the project menu task ‘request license key for project’. A request form is shown within Eclipse, summarizing the simple order process and the meta-data about your application that forms the basis for the license request is also supplied. Jump 2 Java licenses are application unique, i.e., each application needs its own license and an application unique license cannot be used to migrate any other application. The meta-data supplied creates a ‘fingerprint’ that uniquely identifies your application.

However, even after a license has been purchased, smaller changes are allowed in the source code to be migrated. The licence tolerates approximately 5% changes to the source code content, so for example, normal renaming of variables, etc., can be performed. However, adding a vast amount of new files, modules, methods, arguments, GUI controls, etc., makes the license invalid for this application. On the other hand, you can perform as many conversions as you like on the same application using only one license.

We think this is fair deal that also reflects the common use case when converting VB6, and we hope that you feel the same!

So, you inspect the meta-data and request and purchase the license. There are three different pricing options. Either you purchase a license for converting your visual basic application to a swing application, you purchase a license for a JSF application or you purchase a license which you can perform both migrations with. You pay for your license using a secure credit card payment.

Once the payment is verified, you can download the licence from within Eclipse and an email is also sent with a receipt and your licence file attached. You store the ‘licence.txt’ file in the projects ‘license’ directory and then you are ready to go start the actual conversion!

The image to your right shows the major steps in the license request flow.

Watch how to order your first trial free license for Jump2Java.

Convert your VB6 source code to Java

6.The conversion is now performed using the last menu option for the conversion project: the ‘migrate visual basic source code’ option. The full Visual Basic source is now compiled to the equivalent Java version of your target Java platform of choice, i.e., Swing or JSF. In a couple of seconds (depending on your system performance and the size of your project) the complete visual basic source code is converted to Java. The conversion process can be done multiple times, but keep in mind that a new fresh copy is created and hence any changes done to the Java source will be lost.

The image below shows parts of a converted visual basic 6 module. Note, that the compiler does not only convert the code with over a 99% precision rate, handling complex differences in, for example, exception handling, array memory management and array traversals, but it also handles more subtle things like creation of Java doc comments for methods. Read about all great features of the compiler here.

Finally, and very important to emphasize, Jump 2 Java is not just a code crunching tool it actually converts your graphical user interface as well. It you chose to stay with a desktop application user interface, Jump 2 Java the generates and almost identical swing version of the visual basic desktop application.

However, even more advanced, you can chose to transform your application in one go from a desktop application to a web-enabled JSF application. The compiler will then transform your absolute-positioned visual basic application into a div- and style-sheet-based floating web interface. The compiler generates a default look and feel that you then easily can enhance to your needs. Below you can see the result of two conversions of one and the same Visual Basic MDI application, one with Swing as a target and one with JSF as a target.

Watch these two tutorials on how to convert a visual basic application first Java Server Faces (web application) and then to a Java Swing (desktop application).

Done! Now, continue with the rest of your conversion project activities

7.You are now done with the first crucial steps and up to 99% of your visual basic source code has already been turned in to Java source code! However, you still need to solve the missing libraries and controls issues and you probably would like to perform some refactoring of your migrated code. Even though our experience tells us that one typically likes to perform some fixes in the visual basic source and then re-perform the conversion, most of the refactoring is done after conversion.

Read more about our best practices for running your whole a conversion project in this article.