I've created a simple Java project in IntelliJ Idea 2018 and I'm trying to add stdlib
to my project.
After spending hours investigating online I tried doing so the following ways:
- Create a
libs
folder inside thesrc
folder, copy and paste thestdlib.jar
and right-click it and selectAdd as a Library
; - Go to
Project Structure -> Modules -> Dependencies -> + JARs or directories
and selecting the stdlib.jar
I found people complaining about doing this but IntelliJ was not suggesting the import needed to use StdOut
, for example. However, when I add the stdlib.jar
file and package it, IntelliJ instantly suggests the import I should use, and there are no errors whatsoever.
Still, when I try to run the project it invariantly runs into the NoClassDefFoundError
.
I've spent hours investigating this, trying different ways to add the library and import it, but the outcome is always the same.
I've attached a print screen that shows my current project structure, import, and use of the stdlib.jar
.
Really hope you guys can help me. Thanks!
Link to download stdlib-package.jar
- https://introcs.cs.princeton.edu/java/stdlib/stdlib-package.jar
MANIFEST.MF
Manifest-Version: 1.0
Main-Class: com.edgelab.hospital.Application
HOSPITAL_SIMULATOR_JAR.xml
<component name="ArtifactManager">
<artifact type="jar" name="hospital-simulator:jar">
<output-path>$PROJECT_DIR$</output-path>
<root id="archive" name="hospital-simulator.jar">
<element id="module-output" name="HospitalSimulator" />
</root>
</artifact>
</component>
stdlib-package.xml
<component name="libraryTable">
<library name="stdlib-package">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../stdlib-package.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../stdlib-package.jar!/" />
</SOURCES>
</library>
</component>