Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Desktop;
import java.io.File;

import javax.swing.JFileChooser;

public class Main {
    public static void main(String[] args) throws Exception {
        JFileChooser fileChooser = new JFileChooser();
        int a = fileChooser.showOpenDialog(null);

        if (a == JFileChooser.APPROVE_OPTION) {
            File fileToOpen = fileChooser.getSelectedFile();
            Desktop.getDesktop().open(fileToOpen);
        }
    }
}