Issue
I´m trying to get a property file from res folder but I get this error:
Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name res/Interfaz, locale es_ES
This is the project tree:
href="https://i.stack.imgur.com/9xZG4.png" rel="nofollow noreferrer">
And this is my simple code:
public class Main {
public static void main(String args[]) {
System.out.println("Working Directory = " + System.getProperty("user.dir"));
ResourceBundle rb = ResourceBundle.getBundle("res/Interfaz", Locale.getDefault());
//String name = rb.getString("name");
//System.out.println(name); // Si el idioma del sistema es español, imprime "Nombre".
}
}
I´m using Netbeans 12
Solution
Well, I found the solution. As my project is a Maven project, following Maven conventions, I hace to create a new resources folder in the src/main/ directory of the project. This src/main/resources path will automatically be marked as a resource directory next time I build the project using Maven.
And from code I access it as:
ResourceBundle.getBundle("Interfaz", Locale.getDefault());
Answered By - Juan Reina Pascual
Answer Checked By - Cary Denson (JavaFixing Admin)