1

I know, there are lots of similar question around here with similar problems, but after reading tons of posts, I cannot simply solve this issue. In my project I've already marked the resources folder as the Resources Root.
Still, I'm getting null for every Resource file I try to link using a simple command like:

System.out.println(MainClass.class.getResource("config.properties"));

Any hints? Thank you!

Here you can see my project structure:

Project Structure

This is my MainClass.java class.

package dataParser;

import dataParser.Controller.PropertiesManagement;
import dataParser.Controller.RequestDataThread;
import dataParser.Model.WorkpieceData;

import java.net.Socket;
import java.util.Properties;
import java.util.Vector;

public class MainClass {

    // Connection socket.
    private static Socket socket;
    // Stores the workpieces data which have not already been saved in the DB.
    private static Vector<WorkpieceData> workpiecesDataObjectsArray;


    /**
     * Main Method
     */
    public static void main(String[] args) {
        System.out.println(MainClass.class.getResource("config.properties"));
        // First of all let's load the settings from the properties file.
        Properties properties = new Properties();
        PropertiesManagement propertiesManagement = new PropertiesManagement(properties);
        propertiesManagement.readPropertiesFile();

        workpiecesDataObjectsArray = new Vector<>();
        RequestDataThread reqDataThread = new RequestDataThread(socket);

        // New thread to initialize incoming data.
        Thread incomingDataThread = new Thread(reqDataThread);
        // Now let's start the thread.
        incomingDataThread.start();
    }

    /**
     * Getter for the array of workpiece objects.
     *
     * @return The array of workpiece objects to be filled with the data incoming from the control unit.
     */
    public static Vector<WorkpieceData> getWorkpiecesDataObjectsArray() {
        return workpiecesDataObjectsArray;
    }

}
Davide3i
  • 1,035
  • 3
  • 15
  • 35

0 Answers0