Jump to content

How to load modules from a JAR file


This topic is 3599 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, I'm absolutely new to Java and Groovy and I'm trying to figure things out.

 

I have a JAR file, which I loaded using SMLoadJar and it returned no errors.  If I use SMGetLoadedJars I get this:

 

commons-codec-1.4.jar
commons-ssl.jar
commons-io-2.4.jar
ws-timbrado-client.jar
 
Now, I want to use the classes in ws-timbrado-client.jar and I'd like to know:
 
  1. Which classes are contained in the JAR file.
  2. What parameters they use.
  3. How to register those classes as modules so I can create a plugin with them.

Here is the link to download the JAR file:

 

http://solucionfactible.com/sfic/resources/files/librerias/timbrado/ws-timbrado-client.zip

 

Thanks in advance.

 

Ibrahim

Link to comment
Share on other sites

Hi Ibrahim,

 

I also have very little experience with Java/Groovy.

BUT, after a great deal of Googling, trial and error, and patience (did I mention patience?), I was able to create a plugin successfully. In that process, I faced the same issue.

 

Here is what I found:

  1. Which classes are contained in the JAR file.
    1. A .jar file is an archived and compressed folder, like a zip file.
    2. Most utilities which expand .zip files, will expand a .jar file into a folder
      1. I tested it on your .jar file, using Archive Utility.app on the mac

         
  2. What parameters they use.
    1. Any IDE will do, but for your (and my own) basic needs to drill down into the code of a class, I use a handy, cross platform, open source app called 'Java Decompiler': jd.benow.ca
      1. It allows you to explore the root folder of a decompressed jar, in a tree view, select the classes, and see a breakdown of the parameters and code base
      2. Caution: the app will drill down a jar file directly, but it has been my experience that it may not see all the classes in a jar.
        1. Best to decompress the jar into a folder, then use the app on the folder
           
  3. How to register those classes as modules so I can create a plugin with them.
    1. Just use the classes from the jar in your code, just be sure you load the jar.

And this is what brings me here today, and brought me to your thread: jar dependencies.

(I dont mean to go off topic, but you may face this issue next)

 

Following the documentation as best I can, I can not get ScriptMaster to recognize jar files unless I have them in /Library/Java/Extensions (on osx). I have seen this issue mentioned in this forum while I was hunting down other issues, I hope somewhere in here it is thoroughly explained

 

I will be looking for more info about that issue in this forum, but I might have to post the question myself.

(but I will be watching this thread, if anyone wants to respond here.)

Link to comment
Share on other sites

The API documentation is also usually a good start for examples etc

 

didn't take me long to find

http://solucionfactible.com/sfic/capitulos/timbrado/librerias-jar-timbrado-api.jsp

 

only I don't read Spanish

 

 

Once you have loaded a jar file you need to tell the script to use the classes you want

so something like:

 

import com.solucionfactible.cfdi.ws.timbrado.xsd.* will let you use subclasses contained at that point

 

There are certain Java classes you don't need to explicitly import as they are assumed by virtue of being part of Groovy itself

 

Learning Groovy is worth doing by understanding how it works as a language and how its basic building blocks work

start here:

http://groovy.codehaus.org/For+those+new+to+both+Java+and+Groovy

 

or see my previous post about a video...

http://fmforums.com/forum/topic/91574-learning-groovy/

Link to comment
Share on other sites

This topic is 3599 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.