I have my solidity contract

//solidity contract

pragma solidity ^0.4.7;

   contract SimpleStorage { 

    uint public storedData;

      function SimpleStorage(uint initialValue) {
        storedData = initialValue;

       function set(uint x) {
        storedData = x;

       function get() constant returns (uint retVal) {
        return storedData;


And I have JAVA program like this ,

   public class mySpecialClass{

      public int mySpecialfun(int a ,int b){ 
          int c;
            // c =my special treatment of a and b
               return c ;

I want to call mySpecialfun() in my contract


      set(mySpecialfun(5,6) /* 5 and 6 just example   */) 

my problem is to call java program in my contract thank you for your help

  • you can't do that but you can do the reverse – Badr Bellaj Apr 30 '18 at 12:39

The smart contract can't access anything outside the blockchain directly. Everything the smart contract does has to be contained within the blockchain. You can access outside resources only indirectly through something called oracles.

So, your contract can not access your Java program.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.