Search code examples
javaubuntuintellij-ideajava-8java-console

Java/Ubuntu - Print outside of main works on Windows but does nothing on Ubuntu 14.04


I have an Intellij project. I compile ('Make') it on Windows, and sends it onto a Ubuntu 14.04 remote server, running Java 1.8.

My problem is that the System.out.println() outside of the main method prints nothing. I've spent a few hours on this problem, and I can ensure that :

  • I know the methods are executed because they raise Warnings :
    Aug 20, 2016 7:35:36 PM org.apache.pdfbox.cos.COSDocument finalize WARNING: Warning: You did not close a PDF Document

  • When the execution ends, I always get the following output for rates : []

  • Printing the methods as I call them & place print lines at the begining of these methods, won't do the stuff.

N.B. To execute my project, I use : java MyProject.TestAlgo , with TestAlgo the main Class.


EDIT : I expect the output to be a List such as : [1.0, 2.3, ..., 5.4], but I get []

I don't think the problem is programming problem, because whenever I compile it on my computer which runs Windows, I get the prints from outside the main.

When I compile the project, and run it on the Ubuntu remote server, I don't see any output except the prints from the main, and the warnings raised by methods from outside main class. All methods trying to print and called in the main are declared static.


Solution

  • Solved :

    I was compiling Java with the 1.8.0.101 JDK version on Windows, and running it with the 1.8.0.91 on Ubuntu, which (I think) must have created version conflicts..

    I solved the issue by updating Java JRE so I had same versions of Java onto Windows and Ubuntu.