UnsupportedClassVersionError: JVMCFRE003 bad major version in WebSphere AS 7

WebSphere Application Server V7 does support Java Platform, Standard Edition (Java SE) 6 (see Specifications and API documentation in the Network Deployment (All operating systems), Version 7.0 Information Center) and it’s since the release V8.5 when Java 7 has been supported. I couldn’t find the Java 6 SDK documentation, and could only consult IBM JVM … Read more

How to set classpath when I use javax.tools.JavaCompiler compile the source?

The javax.tools.JavaCompiler#getTask() method takes an options parameter that allows to set compiler options. The following message describes an easy way to set them in order to access the calling program’s classpath: You need to configure the standard java file manager to know about the jar files(s) – you use the compiler options argument to do … Read more

Java 1.6 – determine symbolic links

The technique used in Apache Commons uses the canonical path to the parent directory, not the file itself. I don’t think that you can guarantee that a mismatch is due to a symbolic link, but it’s a good indication that the file needs special treatment. This is Apache code (subject to their license), modified for … Read more

How to convert java.lang.Object to ArrayList?

You can create a static util method that converts any collection to a Java List public static List<?> convertObjectToList(Object obj) { List<?> list = new ArrayList<>(); if (obj.getClass().isArray()) { list = Arrays.asList((Object[])obj); } else if (obj instanceof Collection) { list = new ArrayList<>((Collection<?>)obj); } return list; } you can also mix the validation below: public … Read more

The JDK is missing and is required to run some NetBeans modules

Find the file [netbeans installation directory]/etc/netbeans.conf Luckily, Linux has a find helper like find /home/ -name “netbeans.conf, in which you can change the /home/ to a location where you want to search. I found it at /usr/local/netbeans-8.1/etc/netbeans.conf Once, you found the file, the following property needs to be set: netbeans_jdkhome=”[jdk_path]” where you can find the … Read more

How to use TLS 1.2 in Java 6

After a few hours of playing with the Oracle JDK 1.6, I was able to make it work without any code change. The magic is done by Bouncy Castle to handle SSL and allow JDK 1.6 to run with TLSv1.2 by default. In theory, it could also be applied to older Java versions with eventual … Read more

Simple Java HTTPS server

What I eventually used was this: try { // Set up the socket address InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), config.getHttpsPort()); // Initialise the HTTPS server HttpsServer httpsServer = HttpsServer.create(address, 0); SSLContext sslContext = SSLContext.getInstance(“TLS”); // Initialise the keystore char[] password = “simulator”.toCharArray(); KeyStore ks = KeyStore.getInstance(“JKS”); FileInputStream fis = new FileInputStream(“lig.keystore”); ks.load(fis, password); // Set … Read more

How to define a relative path in java

Try something like this String filePath = new File(“”).getAbsolutePath(); filePath.concat(“path to the property file”); So your new file points to the path where it is created, usually your project home folder. As @cmc said, String basePath = new File(“”).getAbsolutePath(); System.out.println(basePath); String path = new File(“src/main/resources/conf.properties”).getAbsolutePath(); System.out.println(path); Both give the same value.