Reputation: 11
I want to get my PC specs with a java program. I'm trying to make use of Oshi library to get this done but I am having problems implementing the dependencies on my project
I want to simply run this
SystemInfo systemInfo = new SystemInfo();
HardwareAbstractionLayer hardware = systemInfo.getHardware();
CentralProcessor processor = hardware.getProcessor();
System.out.println(processor.toString());
I have added these dependencies from this link: https://search.maven.org/artifact/com.github.oshi/oshi-core/6.3.1/jar
Here is a picture of the Project Explorer Project Explorer
I'm pretty sure that I'm doing something wrong with the dependencies, maybe I am not getting the proper dependencies but I want to know what is happening or exactly which jars I need to add to get Oshi running on my java project
Upvotes: 1
Views: 378
Reputation: 641
The issue here is the classpath. The dependencies are added to your build path which allows your code to compile but not to your classpath which is where you need them for your code to run.
As Daniel said
Go to the "Run Configurations" dialog (Run -> Run Configurations) for the class you are executing and click on "Dependencies" there
Also Daniel's suggestion
Do yourself a favor and set up your project using Maven. (Configure --> add Maven nature.). You can add dependencies in your pom.xml file and Eclipse/Maven takes care of all the classpath stuff. (You would only need to add the oshi dependency, and its own pom tells Maven what other dependencies to get.). Your future self will thank you a million times over
is very apt
Upvotes: 1