Unable to run Java GUI programs with Ubuntu

前端 未结 9 749
天命终不由人
天命终不由人 2020-12-03 04:28

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(){
           


        
相关标签:
9条回答
  • 2020-12-03 05:16

    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.

    0 讨论(0)
  • 2020-12-03 05:17

    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.

    0 讨论(0)
  • 2020-12-03 05:19

    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)

    0 讨论(0)
提交回复
热议问题