问题
I have a Java program using Microsoft azure Storage. When I run it on a Windows platform, I get no error, but when I run the same on a Linux platform, I get the following error.
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.microsoft.azure.storage.core.Utility
Would anybody know of any possible explanations?
回答1:
It seems to be a common issue for using Maven to run a Java program on Linux.
When command mvn -v
or do other operations, you will get the issue like below.
Exception in thread "main" java.lang.NoClassDefFoundError: xxxxxxxxx
Caused by: java.lang.ClassNotFoundException: xxxxxxxxxxx
Normally, there are two reasons for this case as below.
The environment variable
M2_HOME
could not be configured at the file. please try to set it up via the commands below.export M2_HOME=<the maven installed path> # for example, /opt/apache_maven/ export PATH=$PATH:$M2_HOME/bin
The current user has no permission to access some files or directories because files or directories uploaded from Windows are missing the linux filesystem permission information. So please try to change the permission for files or directories via the commands below.
chmod -R 660 <the maven project name> # Sometimes, try to use 777.
Hope it helps.
来源:https://stackoverflow.com/questions/40975896/getting-a-java-lang-noclassdeffounderror-in-linux-platform-and-not-windows