Differences between “java -cp” and “java -jar”?

I prefer the first version to start a java application just because it has less pitfalls (“welcome to classpath hell”). The second one requires an executable jar file and the classpath for that application has to be defined inside the jar’s manifest (all other classpath declaration will be silently ignored…). So with the second version … Read more

Spring classpath prefix difference

SIMPLE DEFINITION The classpath*:conf/appContext.xml simply means that all appContext.xml files under conf folders in all your jars on the classpath will be picked up and joined into one big application context. In contrast, classpath:conf/appContext.xml will load only one such file… the first one found on your classpath.

Purpose of buildscript block in Gradle

The buildScript block determines which plugins, task classes, and other classes are available for use in the rest of the build script. Without a buildScript block, you can use everything that ships with Gradle out-of-the-box. If you additionally want to use third-party plugins, task classes, or other classes (in the build script!), you have to … Read more

Get a list of resources from classpath directory

Custom Scanner Implement your own scanner. For example: (limitations of this solution are mentioned in the comments) private List<String> getResourceFiles(String path) throws IOException { List<String> filenames = new ArrayList<>(); try ( InputStream in = getResourceAsStream(path); BufferedReader br = new BufferedReader(new InputStreamReader(in))) { String resource; while ((resource = br.readLine()) != null) { filenames.add(resource); } } return … Read more

What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?

The difference from the Java API Specifications is as follows. For ClassNotFoundException: Thrown when an application tries to load in a class through its string name using: The forName method in class Class. The findSystemClass method in class ClassLoader. The loadClass method in class ClassLoader. but no definition for the class with the specified name … Read more