Solved Method not visible from second plugin

Discussion in 'Plugin Development' started by dram, Apr 27, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    dram

    Hello.

    In one plugin in main class I have made method:

    Code:
    static void test_method(){
    System.out.print("test");
    }
    And in second plugin (where Jar with first plugin was included) i want to execute this method.

    It Means I import main class and use
    main_class.test_method();

    But error is 'test_method is not visible"

    I want to miss getting class handler in second plugin to first plugin. And I'm using static method but still wont work.
     
  2. Offline

    meguy26

    @dram
    1. Visibility is the one of the most basic components of java, I suggest you brush up on your java by purchasing a book or reading the oracle java tutorials.

    2. Simply declare the method as 'public' so it can be accessed from anywhere:
    Code:
    public static void test_method(){
    System.out.print("test");
    }
     
  3. Offline

    dram

    @meguy26 I tried with 'public' result was the same :)

    I think you see that is not communication between classes but between plugins (jars)
     
  4. Offline

    mythbusterma

    @dram

    You have to include one as a dependency of the other, otherwise the "linker" won't resolve it. Also, PLEASE use Java naming conventions, that method looks terrible.
     
    dram likes this.
  5. Offline

    dram

  6. Offline

    meguy26

    @dram
    The posted code did not have "public" without public it would not work... I do not need glasses :p
    also nowhere in your post did you mention trying public.
     
Thread Status:
Not open for further replies.

Share This Page