Hot questions for Using Ubuntu in centos


# java -version
-bash: java: command not found

I have jdk1.8.0_40 this folder in usr/local. When I navigate to the folder and type alternatives --config jar, I get such output

There is 1 program that provides 'jar'.

      Selection    Command
    *+ 1           /opt/jdk1.8.0_40//bin/jar

    Enter to keep the current selection[+], or type selection number: 

These are the content in jdk

bin    include     lib      README.html  THIRDPARTYLICENSEREADME-JAVAFX.txt
db     jre         man


You need to add your installation path to your PATH variable. Bash only looks for executables in the paths defined by your PATH variable.


How can I detect whether a File f is a symbolic link (in the unix sense, as created by ln -s source target) or a normal file/directory?

I am using Java 8 and OS X, CentOS and Ubuntu.

In this question they kind of solve it for Java 6. Is there something better in Java 8?

I would like to later use this in order to handle files and directories on a different file system in a different way.


Take a look at java.nio.file.attribute.BasicFileAttributes.isSymbolicLink() available since Java 7


I have a web application, I have several actions. One of the actions writes some image to a folder out of context, lets say to:


Now, another action copies that image to another folder located inside images, but with a different extension, lets say to:


Now, the first image is get from a form, the second image is get from the path where the first image was saved, both images are written with the same method:

InputStream in = new FileInputStream(origen);
OutputStream out = new FileOutputStream(destination.getAbsolutePath());

while ((len = > 0) {
   out.write(buf, 0, len);

The webapp creates every folder, including "subfolder2/subsubfolder2-1/" using mkdirs() if they don't exist.

This works just fine in my test enviroment running ubuntu 14.04 with apache tomcat 6.0.43, but, on production, is centos 6(or 6.5), same apache tomcat version, the image is created, but no data is written to it, what I mean, is that a image.png file is created, but its size is 0. All folders have the correct permissions, drwxrwxrwx, but image.png for some reason, lacks them, having only rw.

What can be causing this?


For some uknown reason, I just changed how I write my file to:

        InputStream in = new FileInputStream(origen);
        OutputStream out = new FileOutputStream(destination.getAbsolutePath());

        int byteRead = 0;
           byte[] buffer = new byte[8192];
           while ((byteRead =, 0, 8192)) != -1){
               out.write(buffer, 0, byteRead);

And it worked properly, don't know the reason behind it.