How to create environment module including java .jar executable?

77 Views Asked by At

I am trying to create environmental module allowing to use java executable. In my case it is called "trimmomatic-0.39.jar".

I want it to be usable via command: java -jar $TRIMMOMATIC [options]

This is my attempt, which does not work as intended:

#%Module1.0
    
module-whatis "trimmomatic 0.39"

proc ModulesHelp { } {
        global rkoversion

        puts stderr "\ttrimmomatic\n "
    puts stderr "\tTrimmomatic: A flexible read trimming tool for Illumina NGS data\n"
    puts stderr "\thttps://github.com/usadellab/Trimmomatic\n"
}
    
prepend-path PATH       /usr/local/software/trimmomatic/Trimmomatic-0.39/

prepend-path TRIMMOMATIC        /usr/local/software/trimmomatic/Trimmomatic-0.39/trimmomatic-0.39.jar

After loading, if user types following command:

java -jar /usr/local/software/trimmomatic/Trimmomatic-0.39/trimmomatic-0.39.jar -h

it works as intended, but if user provides command:

java -jar $TRIMMOMATIC -h

It does not work correctly. Would appreciate help.

1

There are 1 best solutions below

5
Xavier Delaruelle On

The modulefile described seems correct. In such situation, user should ensure module is correctly loaded. It can be achieved with:

$ module list

If expected modulefile is not found loaded, user should check the available modules to verify this modulefile can be found:

$ module avail

If the modulefile cannot be found in available modules, the modulepath where this modulefile is located should be enabled with:

$ module use /path/to/directory/where/modulefiles/are/located

When modulefile is found among available modulefiles, it can be loaded with:

$ module load modulefile_name

When modulefile has syntax issue, an error is obtained and it is not loaded.

Once modulefile is loaded (it appears in the output of module list command), user can check in its shell session the value set for environment variable:

$ echo $TRIMMOMATIC

If the expected value is obtained with above command, the java -jar $TRIMMOMATIC -h command should perform correctly in the same shell session.