# Java Library with in Java Scope?

**URL:** <https://forum.uipath.com/t/java-library-with-in-java-scope/755863>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, java, activities\
**Created:** [July 24, 2024, 1:58pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863 "2024-07-24T13:58:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diyakapoor](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@diyakapoor](https://forum.uipath.com/u/diyakapoor)\
**Post date:** [July 24, 2024, 1:58pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863/1 "2024-07-24T13:58:48Z")

</div>

Hello experts ,

i am trying to utilise Java code inside UiPath

How do I properly initialize and use a Java library within the Java Scope?

---

<div class="post-metadata">

**Author:** ![lrtetala](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@lrtetala](https://forum.uipath.com/u/lrtetala)\
**Post date:** [July 24, 2024, 2:03pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863/2 "2024-07-24T14:03:54Z")

</div>

Hi @diyakapoor

Check the below thread

> [@How to invoke JAVA code in uipath?](https://forum.uipath.com/t/how-to-invoke-java-code-in-uipath/29765/11):
>
> @poornima_puligadda See the below link. Example : [https://docs.uipath.com/activities/docs/running-static-and-object-methods](https://docs.uipath.com/activities/docs/running-static-and-object-methods)

Regards,

---

<div class="post-metadata">

**Author:** ![sandyarpa767](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@sandyarpa767](https://forum.uipath.com/u/sandyarpa767)\
**Post date:** [July 24, 2024, 2:07pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863/3 "2024-07-24T14:07:59Z")

</div>

Hi @diyakapoor ,

To initialize and use a Java library within the Java Scope in UiPath, follow these steps:

1. **Add the Java Scope Activity** : Drag the `Java Scope` activity into your workflow. Set the `Java Class Path` property to the path of your Java library (.jar file).
2. **Load the .jar File** : Within the `Java Scope`, use the `Load Jar` activity to load your .jar file. Specify the path to your .jar file in the activity properties.
3. **Invoke Java Methods or Create Java Objects** : After loading the .jar file, you can use the `Invoke Java Method` activity to call methods from your Java classes or the `Create Java Object` activity to instantiate Java objects.

Here is a simple example:

```auto
<Java Scope JavaClassPath="C:\path\to\your\library.jar">
  <Load Jar JarFilePath="C:\path\to\your\library.jar" />
  <Create Java Object ClassName="com.example.YourClass" Result="yourJavaObject" />
  <Invoke Java Method TargetObject="yourJavaObject" MethodName="yourMethod" Result="yourMethodResult" />
</Java Scope>

```

Regards  
Sandy

---

<div class="post-metadata">

**Author:** ![diyakapoor](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@diyakapoor](https://forum.uipath.com/u/diyakapoor)\
**Post date:** [July 24, 2024, 2:14pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863/4 "2024-07-24T14:14:25Z")

</div>

Thanks for detailed explanation @sandyarpa767

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [July 27, 2024, 2:14pm UTC](https://forum.uipath.com/t/java-library-with-in-java-scope/755863/5 "2024-07-27T14:14:43Z")

</div>

Closed on July 27, 2024, 2:14pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
