Can I use the variables declared in a script in another script?

I tried by creating a public class and inside declaring the variables as public static, but I'm getting this error when the script is called:

An error occurred while processing the script: 2 Once if pattern matches
The error message was: class bsh.ParseException (line 1): public-- Encountered "public" at line 1, column 1.

Thanks in advance

If you need a value in

If you need a value in another script, you need to set it as a session variable.