In this article, Let’s learn How to Set Destination of the Class File in Java. Before that, let’s understand what is a class file. When we compile a java file, we get a class file. A Java class file is a file containing Java byte-code and having ” .class” extension that can be executed by JVM.
The java file is compiled using javac command as shown below.
In general, when a java file is compiled the generated ” .class” file will also be saved in the same folder. In order to set the destination of .class file we use -d option while compiling the ” .java” file, as shown below:
javac filename.java -d "path to store the .class file"
Source : Gfg.java file in "/home/mayur/" directory Destination :"/home/mayur/folder" directory Command : javac Gfg.java -d "/home/mayur/folder"
Folder Before program execution:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.