Getting Started with the Java Web SDK

MicroStrategy offers several SDKs, but two in particular kind of overlap: the iServer COM SDK and the Java Web SDK.  At first, it sounds like they are for two different things, but in reality they have long since been merging.  Desktop is effectively built from the IServer COM SDK, so anything you can do in Desktop, you can do using that SDK.  Web is built using the Java Web SDK, and the same is true for that. Since the introduction of Web in v7, MicroStrategy has begun merging the two environments ever since.  The IServer COM SDK is slowly being phased out, but it still contains some functionality that the Java SDK doesn’t (like Metric editing, Distribution Services and other Desktop only features).  The Java SDK is the future though, and provides a much better documented framework as well as easier to work with (this isn’t a Java vs VB argument, but rather the framework’s quality).

Today I’ll walk through setting up an Eclipse environment and connecting to MicroStrategy using the Java Web SDK.  Don’t be fooled by the “Web” in the name though, this can be used to build stand alone Java Applications.  I personally have not done much in Web Addon development, but I have written a few stand alone Java apps to do some neat things.

Step 1: Getting Eclipse

You can use any Java IDE you want, but Eclipse is probably the most popular.  If you’re also using MicroStrategy’s Web Customization Editor, which is an Eclipse plugin, then you’ll probably use it for Java development as well.
There are a few different versions of Eclipse, and navigating the Java websites will lead you to a multitude of options with similar sounding names.  I’m no expert, but what works for me is Eclipse  IDE for Java EE.

http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr2

You don’t need to actually install anything, just extract it and run eclipse.exe.  Depending on where it opens by default, you’ll want to be in the Java EE perspective.  You can switch this by going to Window -> Open Perspective.  
Once in here, just create a new Project, Package and Class.  You’ll need to refer to proper Java documentation / tutorials if you need help getting that part setup, but it’s pretty simple.
Step 2: Adding the MicroStrategy SDK files
This part is actually a little sneaky.  If you’re a MicroStrategy customer, you probably know that you have to buy a separate license for the SDK.  Mostly, this includes their documentation and sample libraries.  In a few cases (Web Customization Editor, Visualization SDK and Mobile SDK), this includes the actual SDK files you’ll need to build something.  But in the case of the IServer COM SDK and the Java Web SDK, you actually have the files you need just by installing Desktop alone.
Once again, there’s no “installation” with Eclipse.  You just have to copy the MicroStrategy JAR files into your project.  I personally create a /libs folder under my project and put them in there. 
The files are located in your local installation at:

C:Program FilesCommon FilesMicroStrategy

The files you’ll need are most of the *.JAR files.  As you work with the Java Web SDK, you may encounter the need for more of them, but the most common ones I’ve needed are all of the ones that start with Web*.jar and JavaWebAPI.jar.

Important: If you add every .jar file, you could encounter strange errors (specifically related to some “Decrypt” error).  Only add the Web*.jar and JavaWebAPI.jar unless you explicitly know you need one of the others.

Just copy these files to your /libs or wherever you want to put them.  Then, right click on your project and choose Properties.  Then on the Java Build Path tab, choose the Libraries tab and click Add External JARS.  Select the ones from the /libs folder, and you’re done.
Step 3: Connecting to MicroStrategy
The first thing you’ll need to do in any project is to connect to MicroStrategy and create a session:


import com.microstrategy.web.objects.WebIServerSession;
import com.microstrategy.web.objects.WebObjectsFactory;

WebObjectsFactory factory = WebObjectsFactory.getInstance();
WebIServerSession serverSession = factory.getIServerSession();
serverSession.setServerName("ISERVER");
serverSession.setServerPort(0); //0 means default.
serverSession.setProjectName("PROJECT");
serverSession.setLogin("USER NAME");
serverSession.setPassword("PASSWORD");

Conclusion
After creating your session, you’re good to go on whatever it is you want to build.  Even if you don’t own the SDK, there are lots of good articles on the MicroStrategy Knowledgebase that include fantastic full source code tutorials.  I’ll also be posting code to do specific tasks in future posts, and reference this as the universal starting guide to any project.

You may also like...