Java.lang.ExceptionInInitializerError (running normally in Idea, this error is reported by jar package running)

there is a AAA class with a static member variable custCount , which is an atomic class.
is then used in another class.
in theory, when this member variable is called, the AAA class is loaded and then initialized.
does this when local debug in Idea.
but after the jar package, through the java-jar xxx runtime, An exception will be reported: java.lang.ExceptionInInitializerError .

what a weird mistake.

AAA

:

clipboard.png


:

, edgeCountcustCount:
private static final String STAT_FILE_NAME1 = AAA.class.getClassLoader().getResource("").getPath() + "stat/stat.txt";

AAA.class.getClassLoader().getResource("")jarnull. NullPointerException. , ExceptionInInitializerError""NullPointer.

clipboard.png

:

  • AAA.class.getClassLoader().getResource("").
  • AAA.class.getResource("")(jar).

!!.

clipboard.png

Summary:
my goal is to get the path where the jar package is located . This getResource () mode does not meet my needs in jar package running mode.

previous experiments: new File ("") can get the of the path where the jar package is located. Don"t struggle with it. Let"s use this method for the time being ~

.

ExceptionInInitializerError, leads to more possibilities.
look at you, there is no problem in this IDE, the JAR package reports an error, and then there is a line in the code that loads resource. Is
a loaded local configuration file? check whether it is not included in the jar package

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b331e3-2be85.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b331e3-2be85.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?