We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Instantiation of a Java Class Library
Page Index Toggle Pages: 1
Instantiation of a Java Class Library (Read 692 times)
Instantiation of a Java Class Library
Mar 6th, 2010, 4:19am
 
I work with the SimpleARToolKit and thats just fine.

But now as I get more experienced I would like to use some functions from the underlying JARToolKit.
But I fail already at the very beginning: I cannot instantiate the JARToolKit.

Documentations says:
public static JARToolKit create()
                        throws java.lang.InstantiationException

Here is what I tried:

import net.sourceforge.jartoolkit.core.*;
JARToolKit jk;
try {
  jk=JARToolKit.create();
}
catch (InstantiationException e){
 println("some problem");
}

jk.utilTimerReset(); //this is a very simple JARToolKit function
//Processing tells me in this line: The local variable jk may not been initialized.

I assume, thats a very basic problem but I its quite hard for me to find the answer.
Thnx for any help.
Re: Instantiation of a Java Class Library
Reply #1 - Mar 6th, 2010, 5:51am
 
> //Processing tells me in this line: The local variable jk may not been initialized.

JARToolKit jk = null;

and put a null check around the jk.utilTimerReset(); (or move the whole of your code into the try block so it'll catch any other exceptions in the code. oh, and use println(e) and e.printStackTrace() in the catch - you're just silencing the exception otherwise and it contains useful information that you're just ignoring.)
Re: Instantiation of a Java Class Library
Reply #2 - Mar 6th, 2010, 6:11am
 
Ok great. It just works.
I will now try to understand WHY.
Thnx for the advices also. I will do my best:)
Page Index Toggle Pages: 1