I have this snippet of java code. I am a noob in java..
Error :
expected
cfg = new Config;
Code:
Yes, this is the problem:
public class ClosureBuilder {
cfg = new Config();
...
}
At the top level of a class, you can only have:
{ ... }
)static { ... }
)This is none of these. If you meant to declare a variable, you should have done so:
private Config cfg = new Config();
If that's not what you intended to do, you should explain your intention.
EDIT: Once you've fixed that, this compiler error seems pretty clear:
class Config is public, should be declared in a file named Config.java
There are two potential fixes for this:
Config
non-publicConfig.java
Either should fix that error (potentially revealing more).
Though your intention is not very clear, i assume you want to have the cfg created before any other variable. First declare your class Config as non-public or move to file Config.java. It makes sense to initialize cfg in a static block. Below is a possible code snippet:
private static Config cfg = null;
private static String JDBC = null;
static {
cfg = new Config();
JDBC = cfg.getProperty("JDBC");
}
Where are you declaring your cfg
variable?
I only see the assignment. I think that may be the reason.
Config cfg = new Config();
Shoud fix it.