I'm trying to create a new JarFile using an existing File object but I keep getting a java.util.zip.ZipException: error in opening zip file.
I'm running the code below:
File x= new File("C:/Users/Priyanka/Documents/hello.java");
JarFile jarF = new JarFile(x);
when I run the code above I keep getting the error below:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at prioritization.cfg.Test1.main(Test1.java:12)
I have tried this code on different machines and different version of eclipse but I keep getting the same issue.
I'm have tried to research the problem online but most of the solutions are about trying to open an existing .jar file.
Any help would be appreciated.