Steps for jar file:- --->jar -cvf MyJarFile.jar CreateAJarFile.class //This is for jar file creation
The benefit of storing your class file in a jar file is that you can execute your class from any location on the file system. To illustrate this important point, navigate to the directory above the one where the class file is stored.
--->java -cp ./create-a-jar-file-in-java/MyJarFile.jar CreateAJArFile // Successfully executed the class file
Execute the Java runtime launcher with the
The benefit of storing your class file in a jar file is that you can execute your class from any location on the file system. To illustrate this important point, navigate to the directory above the one where the class file is stored.
--->java -cp ./create-a-jar-file-in-java/MyJarFile.jar CreateAJArFile // Successfully executed the class file
Execute the Java runtime launcher with the
cp
(classpath) option. Notice that the path specified on the classpath option references the directory that contains the jar file.
No comments:
Post a Comment