0
I made the following program in java to automatically swap a file in a computer directory:
public static void main(String[] args) throws IOException {
if (!new File("C:\\ProgramData\\Microsoft\\Network\\Connections\\Pbk").exists()) {
new File("C:\\ProgramData\\Microsoft\\Network\\Connections\\Pbk").mkdirs();
} else {
}
File r = new File("C:\\Users\\ALMIRANTE\\Desktop\\rasphone.pbk");
File d = new File("C:\\ProgramData\\Microsoft\\Network\\Connections\\Pbk\\ra
sphone.pbk");
if (d.exists())
d.delete();
FileChannel rChannel = null;
FileChannel dChannel = null;
try {
rChannel = new FileInputStream(r).getChannel();
dChannel = new FileOutputStream(d).getChannel();
rChannel.transferTo(0, rChannel.size(),
dChannel); //System.out.println("ok");
} finally {
if (rChannel != null && rChannel.isOpen())
rChannel.close();
if (dChannel != null && dChannel.isOpen())
dChannel.close();//System.out.println("ok");
}
}
}
It worked properly for Netbeans. But when building it, go to the folder "dist" and click on the file . generated jar, nothing occurs, that is, the program does not do what it should do. Only a black screen of the windows itself opens and closes quickly.
From my researches I saw that it could be something related to the main class, especially that it certainly would not be defined. However, I have already defined the class, which is: rasphonefile.Rasphonefile.
When going to cmd and put java -jar Rasphonefile.jar, the following error occurs:
Unable to access jar file Rasphonefile.jar
When executing, also at the command prompt, the code java tfv Rasphonefile.jar, which tests the contents of the file, it says unable to locate or load the main class.
Does anyone know the possible causes of this? Thank you!!!!!!