Home
Analytics
Adding .jar file to Rptdesign
New_Bee
<p>Hi,</p>
<p> </p>
<p> </p>
<p>I have a rptdesign in one project and a pojo class in another project. I have created a .jar file of the pojo class.<br><br>
I need to add the .jar to the rptdesign.<br><br>
I select the rptdesign -> go to property editor tab -> select resources from left nav </p>
<p> </p>
<p>I can see Properties files, jar files and javascript files.<br>
When I try to add the jar file, the pop up shows "shared resources" and there is no way to choose the .jar file of the class that I want to add.</p>
<p> </p>
<p>How to add the .jar file to the rptdesign ?<br><br>
Any help will be much appreciated.</p>
<p> </p>
<p>Thanks</p>
<p> </p>
Find more posts tagged with
Comments
micajblock
<p>Copy the jar to report project folder. The jar file needs to be part of the resources of the BIRT project.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>You can refer to a jar class that is located in a different Eclipse project by going to the Properties of your BIRT project and adding JAR files in Report Design --> Classpath --> Add JARs. </p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
pricher
<p>Hi again,</p>
<p> </p>
<p>From a best practice point of view, Mica's approach is better. Putting your JAR file directly within your BIRT project will make your deployment easier. Moreover, if you use a POJO as a data source, only JAR files located in the BIRT project will be visible to the POJO Data Source UI.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
New_Bee
<p>Hi,</p>
<p> </p>
<p>Thanks for the responses.<br><br>
But I'm still unable to get the jar in my shared resources. I tried the following three ways :</p>
<p> </p>
<p>1. <strong><em>Report Project -> Properties -> Report Design -> Classpath -> Add external jars </em></strong> --- then I added the jar but I'm not seeing it when I try to add jar files to rpt design</p>
<p> </p>
<p>2. <strong><em>Directly added .jar file to Report Project</em></strong> -still I'm not seeing it when I try to add jar files to rpt design.</p>
<p> </p>
<p>3. <strong><em>Report Project -> Properties -> Report Design -> Classpath -> Add jars -> selected the jar file from the Report Project itself (added to project in step 2 above) </em></strong> --- then I added the jar but I'm not seeing it when I try to add jar files to rpt design.</p>
<p> </p>
<p> </p>
<p>I'm using BIRT 4.3.2</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Option 2 above should work. Can you export your project and post it to the forum?</p>
<p> </p>
<p>Thanks,</p>
<p> </p>
<p>P.</p>
micajblock
<p>If you used the file system to copy the jar you will need to refresh the project in BIRT.</p>
New_Bee
<p>Thanks for the responses. <br><br>
I'm able to get the jar file in shared resources and I have now added it to the rptdesign. I did the following :</p>
<p> </p>
<p><em><strong>Report Project -> Properties -> Report Design ->Resource -> Resource Folder - > ${workspace_loc: Report_Project_Name}</strong></em></p>
<p> </p>
<p>After this I was able to get the .jar file in shared resources.<br><br><br>
But I'm facing another problem now. </p>
<p>I have a hashmap in the .jar file and I need to read the values from the .jar's hashmap and use in my report. I'm doing the following:</p>
<p> </p>
<p><strong>importPackage(Packages.com.demo.abc);<br>
var obj= new myClass1(); </strong><span style="font-size:12px;">//<em> the .jar </em></span><em>of the class "myClass1"</em><em> is added to the rptdesign </em></p>
<p> </p>
<p><strong> <br>
sortedMap = new TreeMap(obj.hmap); </strong><span style="font-size:12px;"><em>// hmap is the hashmap in the class "myClass1"</em></span></p>
<p><strong>.</strong></p>
<p><strong>.</strong></p>
<p><strong>.</strong></p>
<p><strong><code follows></strong></p>
<p> </p>
<p> </p>
<p>I'm getting the following error :</p>
<p> </p>
<p><em><strong>ReferenceError: "myClass1" is not defined. (/report/method[
@name="
;beforeFactory"]#5)</strong></em></p>
<p> </p>
<p> </p>
<p>Thanks</p>
micajblock
<p>Please start a new topic as this is new question and will help others later searching for answers.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>Where you instantiate your class, use the full package name, as in:</p>
<p> </p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><strong>var obj= new </strong><strong>com.demo.abc.</strong><strong>myClass1(); </strong><span style="font-size:12px;">//<em> the .jar </em></span><em>of the class "myClass1"</em><em> is added to the rptdesign </em></p>
<div> </div>
<div>Hope this helps,</div>
<div> </div>
<div>P.</div>
New_Bee
<p>Thanks for the response
@pricher
. I'm still facing issues though. </p>
<p> </p>
<p>
@mblock
Sure I'll start a new topic for this new issue.</p>