Static referencing of classes and functions in library
              in 
             Library and Tool Development 
              •  
              2 years ago    
            
 
           
             Hello, 
            
             
            
            
             
            
            
             
              
            
            
             
            
            
             
              
            
            
             
            
             
            
            
             
              
            
            
             
            
             
            
            
             
             
           
 
            
           
             I just managed to compile procesing library template in Eclipse, and I'm trying to move some N-dimensional vector operations to this library. I'm not very familier with pure java or eclipse (just with C and Fortran), so I'm a bit confused about thinks like static, final, abstract, interface .... and that everything in java must be inside class.
            
            
             My problem:
            
            
             I would like to reference function from my library without creating an instance of the class.
            
            
             for example I have this simple library in Eclipse:
            
            - package template.library
- import processing.core.*;
- import java.lang.Math;
- public class HelloLibrary {
- public final double rndBell(){
- double a = Math.random();
- double b = Math.random();
- double c = Math.random();
- double r = (a+b+c)*0.33333333 -1.0;
- return r;
- }
- }
              I would like to call 
              rndBell() in processing like this:
            
            - import template.library.Hellolibrary.*;
- println( rndBell() );
             But to do this it would be necessary (probably) to make 
             HelloLibrary static (?) which Eclipse says is not possible (why?)
            
            
             so I need before calling rndBell create instance of the class ( which I don't wan't ) like this:
            
            - import template.library.*;
- HelloLibrary hello = new HelloLibrary(this);
- println(hello.rndBell());
              =======================================================
             
=======================================================
            
             an other problem is that eclipse template there are set some paths: 
            
            - classpath.local C:\Documents and Settings\asiJa/Documents/workspace/libs
- sketchbook C:\Documents and Settings\asiJa/Documents/Processing
- classpath.local C:\Documents and Settings\asiJa\workspace\libs
- sketchbook C:\Documents and Settings\asiJa/Plocha/Processing
             But it's not a big issue, I just must copy compiled library always to the correct location
            
             
              
              1  
            
 
            
 
 
           
 
             
             