I'm new to Java GUI programming and I want to make a Java GUI application which can run both in Windows and Linux with the same code (the same executable/object file).
Is that possible without any compatibility problems/errors/bugs?
What else (like libraries, classes, packets) will I need to be able to design the GUI in Java?
Should these libraries be present in every computer and every OS to be able for the application to run? Or the Java Virtual Machine (JVM) installed on a computer is enough?
Swing is the framework that can help you write GUI applications in Java. Have a look at the Swing tutorial from Oracle: http://docs.oracle.com/javase/tutorial/uiswing/
About platform compatibility: Most Linux distribution installs OpenJDK (open source alternative of Java) as default Java compiler. Mostly it works fine with the program written with Oracle JDK. But if you want to be sure, you can install Oracle JDK on Linux too.
About development IDE: Eclipse and Netbeans are both available across multiple platforms including Windows and Linux.
javax.swing.*, already included into JRE/JDK)Swing will do this for you. It's not as pretty as native UI, but it works well and doesn't require any 3rd party libraries: http://docs.oracle.com/javase/tutorial/uiswing/