Results 1 to 5 of 5
  1. #1
    skydog is offline Member
    Join Date
    Sep 2015
    Posts
    6
    Rep Power
    0

    Default overloaded method - compilation error during runtime

    Hi guys,

    I am calling the connect method of a class as follows:

    Java Code:
    private static  String oMyIP = new String("127.0.0.1");
    private static  int oMyPort = 30303;
    private static String oMyString = new String("");
    oEthereum.connect(oMyIP, oMyPort, oMyString);
    The connect method is an overloaded method and this are the 3 different interfaces:

    Java Code:
        void connect(InetAddress addr, int port, String remoteId);
    
        void connect(String ip, int port, String remoteId);
    
        void connect(Node node);
    During the execution, I get this error:
    XML Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    	The method connect(Node) in the type Ethereum is not applicable for the arguments (String, int)
    	Type mismatch: cannot convert from void to ArrayList<Account>
    I am calling the method with 3 parameters, but the compiler complains in runtime about the method with one parameter (Node). Am I missing anything?

    Regards,
    Skydog

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: overloaded method - compilation error during runtime

    Can you make a small complete example that compiles and shows the problem?

    There isn't a method that matches this: the arguments (String, int)
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    skydog is offline Member
    Join Date
    Sep 2015
    Posts
    6
    Rep Power
    0

    Default Re: overloaded method - compilation error during runtime

    Hi Norm,

    this is the source code:


    package com.atur.uzz.core.ter;


    import java.net.URL;
    import java.util.ArrayList;


    import org.apache.log4j.PropertyConfigurator;
    import org.ethereum.core.Account;
    import org.ethereum.core.Repository;
    import org.ethereum.core.Wallet;
    import org.ethereum.facade.Ethereum;
    import org.ethereum.facade.EthereumFactory;




    public class FSBP006 {


    private static final Ethereum oEthereum = EthereumFactory.createEthereum();
    private static final String oMyIP = new String("127.0.0.1");
    private static int oMyPort = 30303;
    private static final Wallet oMyWallet = oEthereum.getWallet();
    private static final Repository oMyRepository = (Repository) oEthereum.getRepository();
    // private static final ArrayList oAccountList = new ArrayList<>();
    private static Account oAccount;
    private static final String oMyString = new String("1");



    public static void main(String[] args) {




    URL configFile = ClassLoader.getSystemResource("frontier-custom.json");
    PropertyConfigurator.configure(configFile);


    FsBp001 myBusinessPartner = new FsBp001();
    myBusinessPartner.myMessage();


    oEthereum.connect(oMyIP, oMyPort, oMyString);
    oMyWallet.addNewAccount();
    oAccount = new Account();




    System.out.println("test");
    }


    }


    And the error during the execution is:

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    The method connect(Node) in the type Ethereum is not applicable for the arguments (String, int)
    Type mismatch: cannot convert from void to ArrayList<Account>


    at com.atur.uzz.core.ter.FSBP006.main(FSBP006.java:53 )

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: overloaded method - compilation error during runtime

    Sorry, I can't do anything with the code you have posted.
    Where is line 53? Are there 53 lines of code in your post?
    Note: the posted code does not compile for testing because it uses third party packages and has many missing class definitions.

    Please edit your post and wrap the code in code tags to preserve its formatting.
    Last edited by Norm; 10-18-2015 at 06:17 PM.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    skydog is offline Member
    Join Date
    Sep 2015
    Posts
    6
    Rep Power
    0

    Default Re: overloaded method - compilation error during runtime

    Hi Norm,

    you are right, there are no 53 lines of code in the class, but that's what eclipse is telling, it is weird.

    I have created a new project and the application is running.

    I have a build.gradle file which contains the following code:

    springBoot {
    mainClass = "src.FSBP005"
    }
    I have changed it to:

    springBoot {
    mainClass = "src.FSBP0006"
    }
    and now it works. But I still dont know if it works because I made a new eclipse project of because I changed the SpringBoot. I have to say that I start the program as an application and not as a "gradle run"

    Regards
    Skydog

Similar Threads

  1. Replies: 0
    Last Post: 10-04-2013, 05:27 AM
  2. Replies: 3
    Last Post: 03-30-2013, 02:33 AM
  3. Change of access modifier of overloaded method
    By java4amanda in forum New To Java
    Replies: 10
    Last Post: 01-02-2012, 08:17 PM
  4. Runtime error in a method
    By Pojahn_M in forum New To Java
    Replies: 8
    Last Post: 08-02-2011, 04:23 AM
  5. Overloaded method
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •