Getting a java.lang.NoClassDefFoundError in Linux platform and not Windows

让人想犯罪 __ 提交于 2019-12-12 04:29:41

问题


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.

  1. 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
    
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!