Category Archives: java

RMI local class incompatible

When loading external classes using RMI, it is key to compile against same jars as the ones used in target system. If not, RMi local class incompatible error can be thrown because class id between two jar compilations will be different. As such serialization and de serialization will not work properly, throwing this error. Re-mediation is to always fetch jars corresponding to the environment against which app is developed and place them in the classpath. sources

tips for easier development with java

Java is quite verbose and can be very frustrating when being used to more “efficient” languages. Fortunately some guys out there are trying to make things simpler… How-to list join / concatenate list of strings: StringUtils.join(List<String>, String join); // import org.apache.commons.lang3.StringUtils; split a string: StringUtils.split(String str, String sep);// import org.apache.commons.lang3.StringUtils; read entire file and store into a string (JDK 7): StringUtils.join(Files.readAllLines(Paths.get(“file”), StandardCharsets.UTF_8)); // import org.apache.commons.lang3.StringUtils; switch perspective in eclipse: CTRL+F8 CLI library: commons-cli // convert list of strings into list of integers: for(String s : strList) intList.add(Integer.valueOf(s)); list folder content: use FileUtils.listFiles from Apache commons get stack trace as […]

eclipse: selection does not contain a main type [solved]

I am new to Java and Eclipse. After following scrupulously a tutorial to run a simple “Hello World!” app in java, when executing my very simple .java file in eclipse, I got following error: selection does not contain a main type To solve that, right click on the navigation panel on the folder containing my source file > Build Path >  Use as source folder. Bingo! Now pressing run displayed my Hello World message sources