Hello.java 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import javax.swing.*;
  2. import java.io.PrintWriter;
  3. import java.awt.Font;
  4. public class Hello extends JFrame {
  5. public static void main(String args[]) {
  6. new Hello();
  7. try {
  8. PrintWriter writer = new PrintWriter("results.txt", "UTF-8");
  9. writer.println("Java: " + System.getProperty("java.runtime.name"));
  10. writer.println("Java Version: " + System.getProperty("java.version"));
  11. writer.println("OS Name: " + System.getProperty("os.name"));
  12. writer.println("OS Version: " + System.getProperty("os.version"));
  13. writer.println("OS Architecture: " + System.getProperty("os.arch"));
  14. writer.println("Total Memory (MB): " + Runtime.getRuntime().totalMemory() / (1024*1024));
  15. writer.println("Max Memory (MB): " + Runtime.getRuntime().maxMemory() / (1024*1024));
  16. writer.close();
  17. } catch (Exception ex) {
  18. System.out.println(ex.toString());
  19. }
  20. }
  21. Hello() {
  22. JLabel l = new JLabel("Hello Java");
  23. l.setFont(new Font("Serif", Font.PLAIN, 24));
  24. add(l);
  25. setSize(200, 100);
  26. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27. setVisible(true);
  28. }
  29. }