String [ ] getJavaClassPathArguments ( String jarNamePrefix , String mainClass ) { LOGGER . entering ( ) ; Set < String > uniqueClassPathEntries = new LinkedHashSet <> ( ) ; // find all jars in the SELION_HOME_DIR if ( getLauncherOptions ( ) . isIncludeJarsInSeLionHomeDir ( ) ) { Collection < File > homeFiles = FileUtils . listFiles ( new File ( SeLionConstants . SELION_HOME_DIR ) , new String [ ] { "jar" } , false ) ; for ( File file : homeFiles ) { if ( file . getName ( ) . startsWith ( jarNamePrefix ) || StringUtils . isEmpty ( jarNamePrefix ) ) { uniqueClassPathEntries . add ( file . getAbsolutePath ( ) ) ; } } } // find all jars in the current working directory if ( getLauncherOptions ( ) . isIncludeJarsInPresentWorkingDir ( ) ) { Collection < File > localFiles = FileUtils . listFiles ( SystemUtils . getUserDir ( ) , new String [ ] { "jar" } , false ) ; for ( File file : localFiles ) { uniqueClassPathEntries . add ( file . getName ( ) ) ; } } // remove any duplicates that were already in the existing classpath. add the left-overs if ( getLauncherOptions ( ) . isIncludeParentProcessClassPath ( ) ) { String classpath = SystemUtils . JAVA_CLASS_PATH ; uniqueClassPathEntries . addAll ( Arrays . asList ( classpath . split ( SystemUtils . PATH_SEPARATOR ) ) ) ; } // build the -cp [option] StringBuilder buf = new StringBuilder ( ) ; for ( String s : uniqueClassPathEntries ) { buf . append ( s + SystemUtils . PATH_SEPARATOR ) ; } buf . deleteCharAt ( buf . length ( ) - 1 ) ; String [ ] args = new String [ 3 ] ; args [ 0 ] = ( "-cp" ) ; args [ 1 ] = buf . toString ( ) ; args [ 2 ] = mainClass ; LOGGER . exiting ( args ) ; return args ; }
Get the classpath for the child process . Determines all jars from CWD and SELION_HOME_DIR . Does not recurse into sub directories . Filters out duplicates .