I’m getting this weird compilation error with eclipse in the following code block. I’ve included the necessary jars and also tried restarting eclipse but no avail.
public class ControlServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
ResourceBundle rb1;// error on this line
rb1 = ResourceBundle.getBundle("connection_config");
Logger log = LoggerFactory.getLogger(ControlServlet.class);
The error message displayed is:
Multiple markers at this line
- Syntax error on token ";", , expected
- Watchpoint:ControlServlet [access and
modification] - rb1.
Any idea why this could be happening ? And how I could work around this would be helpful.
You are getting this error because you can not write assignment statement and declaration as 2 statements in a class (outside of any
method or staticblock with class variables).So your error is actually on this statement:
You
can not write such a statement in class without surrounding static/method block.cannot write outside of any method or any initialization block (static or non-static). So you have to combine your 2 statements into 1 like: