You need to have your locale name in your properties file name.
Rename your properties file to Messages_es.properties
Since you haven't declared any package, both your compiled class file and the properties file can be in the same root directory.
EDIT in response to comments:
Lets say you have this project structure:
test\src\foo\Main.java (foo is the package name)
test\bin\foo\Main.class
test\bin\resources\Messages_es.properties (properties file is in the folder 'resources' in your classpath)
You can run this with:
c:\test>java -classpath .\bin foo.Main
Updated source code:
package foo;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JFrame;
public class Main {
public static void main(String[] args) {
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale("es");
messages = ResourceBundle.getBundle("resources.Messages", currentLocale);
System.out.println(messages.getString("Messagesgreetings"));
System.out.println(messages.getString("Messagesinquiry"));
System.out.println(messages.getString("Messagesfarewell"));
}
}
Here as you see, we are loading the properties file with the name "resources.Messages"
Hope this helps.
Marimuthu Madasamy
2010-08-01 18:36:15