Completing code to display jar file name

Report a typo

You're developing a Java application that needs to work with .jar files. When running the application, it should accept the file name of the .jar file as an argument and display its name. The relevant code snippet has been provided below, but it contains a number of blanks that need to be filled in. Can you complete the code?

Fill in the gaps with the relevant elements
import java.util.jar.*;

public class ArchiveDemo {
    public static void (String[] args) throws Exception {
         jarFile = new JarFile(args[0]);
        System.out.println("Jar file: " + jarFile.getName());
    }
}
mainJarFile
___

Create a free account to access the full topic