System started Rule shouts Null Error


if I try to write a Rule as following:

rule "Initialize on System start"
System started
HashMap<String,String> myMap = new HashMap

the Log Message “Error during the execution of startup rule ‘Initialize on System start’ : null” comes after saving the rule. But why? Can’t I initialize a Map on System start?

Okay, at this point it was my fault. The initialization of the HashMap must be like:

HashMap<String,String> myMap = newHashMap

But now there is a new error message in the log:
“‘get’ is not a member of ‘java.util.HashMap’”

What does it mean? I want to use the command:


I’m surprised you are not selling syntax errors. You are missing the val. Also, defining it is a System started rule doesn’t do much for you as any variable defined in a Rule goes away as soon as the Rule exits.

You need to define it as a global if you want to use it across multiple Rules.

Finally, in my experience, there is usually a better way to achieve whatever you are after using Items and Groups and the Design Patterns.