# Unable to run java code with classpath on a remote server

**URL:** <https://forum.ansible.com/t/unable-to-run-java-code-with-classpath-on-a-remote-server/32944>\
**Category:** Ansible Project\
**Created:** [May 15, 2020, 7:17pm UTC](https://forum.ansible.com/t/unable-to-run-java-code-with-classpath-on-a-remote-server/32944 "2020-05-15T19:17:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [May 15, 2020, 7:17pm UTC](https://forum.ansible.com/t/unable-to-run-java-code-with-classpath-on-a-remote-server/32944/1 "2020-05-15T19:17:25Z")

</div>

In order to run java code I need to first set the classpath of dependent libraries by running a script setWLSEnv.sh as below:

`$ . /app/wlserv*/server/bin/setWLSEnv.sh $ java weblogic.version`

The output gives me the version of the product which I need.  
I wrote the below playbook but it does not run the java code.

`

---

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [May 16, 2020, 8:33am UTC](https://forum.ansible.com/t/unable-to-run-java-code-with-classpath-on-a-remote-server/32944/2 "2020-05-16T08:33:12Z")

</div>

I found the solution myself. Here it is:

```auto
---
  - hosts: dest_nodes

    tasks:
      - name: Get weblogic CLASSPATH
        shell: "/app/wlserv*/server/bin/setWLSEnv.sh"
        register: wlsenv

      - name: Get weblogic Version
        shell: "java weblogic.version"
        environment:
          CLASSPATH: "{{ wlsenv.stdout }}"
        register: wlsversion

      - debug:
          msg: "{{ wlsversion }}

```
