Search code examples
javatoml

Read from toml file java


I am using toml with java for the first time.I configured the pom.xml dependencies and i want to read from the .toml file.

Toml toml = new Toml().read(new FileInputStream("/home/abdallah/Desktop/config.toml"))

I am getting this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson

Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson

It is giving me this error in this line of code.I want to ask how can i read the toml file in java using the .read() method

thank you


Solution

  • The problem is that you added toml dependency in maven , but you didn't add com.google.gson , and thus the error is not the .read method. Add com.google.gson dependency and it works!