I am learning GUI in Java, and for that I have created a demo program:
import java.awt.*;
public class FrameDemo extends Frame {
public FrameDemo(){
This command worked for me.
Sudo dnf install java-1.8.0-openjdk
(Fedora)
Sudo apt-get install java-1.8.0-openjdk
Should work for Ubuntu.
Use JFrame instead of Frame. And do not extend from JFrame. Just write a class that has a JFrame property named gui
, which configures this JFrame with the available methods, because it is better style doing it like this. Extending here is wrong the use of OOP.
I too had OpenJDK on my Ubuntu machine:
$ java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.04.2)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
Replacing OpenJDK with the HotSpot VM works fine:
sudo apt-get autoremove openjdk-7-jre-headless
How to install the JDK on Ubuntu (Linux)