Compiler error cannot find symbol - Java
NickName:user2425977 Ask DateTime:2013-05-28T02:31:18

Compiler error cannot find symbol - Java

First, I am very new to Java and my programming in general is rusty. So I might have missed something very simple.

The error:

cannot find symbol
symbol  : method setMethod(java.lang.String)
location: class ij.plugin.Thresholder
        Thresholder.setMethod("Mean");

Some code snippets: This part is third party code. I would like to avoid modifying this as much as possible

public class Thresholder implements PlugIn, Measurements, ItemListener {
    private static String staticMethod = methods[0];

    public static void setMethod(String method) {
        staticMethod = method;
    }
}

My code (well, some relevant parts)

    import ij.plugin.Thresholder;
    public class CASA_ implements PlugInFilter,Measurements  {
    public void run(ImageProcessor ip) {
        track(imp, minSize, maxSize, maxVelocity);
    }

    public void track(ImagePlus imp, float minSize, float maxSize, float maxVelocity) {
        Thresholder.setMethod("Mean");         <-- This is the line the compiler hates
    }
}

Why is the compiler looking for a setMethod method with a return of something other than void?

Thanks

Copyright Notice:Content Author:「user2425977」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/16778703/compiler-error-cannot-find-symbol-java

Answers
Makoto 2013-05-27T18:35:12

You can't call a method in a class declaration block. You can either do it in the constructor or in another method (that then has to be explicitly called on that class).",


More about “Compiler error cannot find symbol - Java” related questions

Compiler error cannot find symbol - Java

First, I am very new to Java and my programming in general is rusty. So I might have missed something very simple. The error: cannot find symbol symbol : method setMethod(java.lang.String) locat...

Show Detail

Java Compiler Issue: cannot find symbol

I am trying to format a String into a date but getting java compiler error: The fragment of code is: String value = String.valueOf(entry.getValue()); SimpleDateFormat formatter = new SimpleDateF...

Show Detail

Cannot Find Symbol compiler message

Hello all I'm a java newbie and I'm getting a compiler error message: src\LU62XnsCvr.java:33: cannot find symbol symbol : constructor File(java.lang.StringBuffer) location: class java.io.File ...

Show Detail

Java compiler says cannot find symbol. why?

I followed this: https://mahout.apache.org/users/recommender/userbased-5-minutes.html and my codes : pom.xml Note that my &lt;groupId&gt; is also org.apche.mahout &lt;project xmlns="http://maven.

Show Detail

Java compiler error. Cannot find symbol

Why am I getting this error when the SystemController class is in the same directory? sgs$ javac Main.java Main.java:27: cannot find symbol symbol : class SystemController location: class sgs.M...

Show Detail

Java "cannot find symbol" error

I am trying to make an Uber jar in Intellij and have run across this issue with maven shade. I have looked at other solutions but nothing seems to work. My project is to make a plugin for Minecraft...

Show Detail

Learning java, cannot find symbol

I'm learning Java and stuck on a self test exercise writing a recursive function that prints a string backwards... I understand the compiler error but I'm not sure what to do about it. My code...

Show Detail

maven compiler 3.1 cannot find symbol

for the error reproduction, I created a demo project: https://github.com/boyang9602/demo . I have read Maven compile &quot;Cannot find symbol&quot;, What does a &quot;Cannot find symbol&quot; or &q...

Show Detail

How to suppress Cannot Find Symbol error when compiling java?

I'm using Dagger, Room and DataBinding to develop my application, these libraries generate massive codes. When something wrong happened in my code, these libraries stop generating codes and produce

Show Detail

Cannot find symbol error in Java with args[]

I am a beginner in Java. I am trying to write a program that takes two numbers and a string as a command line argument and it prints out the substring specified by the two numbers. For example: %

Show Detail