0

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?

Aparna
  • 835
  • 2
  • 23
  • 47
  • How did you install the dependencies on Linux ? Via maven ? – sguler Dec 05 '16 at 20:12
  • The program is compiled and built on a windows platform..maven was used to build it.....it can be run on a Linux or windows platform. I didn't have to install the dependencies separately on Linux because I was just running the compiled code which included the dependencies during build – Aparna Dec 06 '16 at 11:50
  • @Aparna Did you configure the `M2_HOME` environment variable for Maven on Linux, and add it into `$PATH`? – Peter Pan Dec 07 '16 at 03:00

1 Answers1

0

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.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43