+ Start a Discussion
AnushaAnusha 

How to access the Static resource from Apex Class

HI,

I have a small issue...

I uploaded one .jar file in Static resource. It's contains some .class files.

now i want to use one those .class file in my Apex Code.

Please tell me how to use this.

 

Thanks & Regards

Anusha

 

Best Answer chosen by Admin (Salesforce Developers) 
AnushaAnusha

Yeah it's solved, wecan't invoke a static resorce from a Class.

 and 

@ Mel1, i asked about from Class not from page. anyway thanks for your intrest.

Thankyou

All Answers

sebcossebcos

Hi Anusha,

what you are trying to do is not possible in Apex, you cannot use Java libraries from within Apex.

There are some Apex libraries that one can use for development in their own Apex code.

Please look into Code Share to find them: Code Share . An example library is apex-lang: apex-lang - Project Hosting on Google Code which ports some common libraries to Apex.

If you really need to use Java code you can build a webservices application which allows for the usage of Java and its libraries. This type of applications are not running natively on Salesforce.com but need to be hosted on other clouds or servers.

 

Mel1Mel1

I use static resources within my page via apex as follows.

 

<apex:stylesheet value="{!$Resource.MY_Sites_CSS}"/>
<apex:image url="{!URLFOR($Resource.MY_VALUE)}"/>
<option value="{!URLFOR($Resource.MY_DOCUMENT)}">  for one of the options.

 

For Help, the example for using .js in apex is

<apex:includeScript value="{!URLFOR($Resource.LibraryJS, '/base/subdir/file.js')}"/>

 help link: http://www.salesforce.com/us/developer/docs/pages/Content/pages_resources.htm

Bhawani SharmaBhawani Sharma

Hi Anusha,

 

What you want to do with .class files ?

AnushaAnusha

Yeah it's solved, wecan't invoke a static resorce from a Class.

 and 

@ Mel1, i asked about from Class not from page. anyway thanks for your intrest.

Thankyou

This was selected as the best answer
NisseKnudsenNisseKnudsen

Why don't you use a HttpRequest for that? I don't know if you could use a global variable for file name and path, but if you'd address it directly, shouldn't be a problem.

Surely, you have to see if this meets your demands regarding later processing!

 

Cheers!