To Compile: javac -d . Simple.java
To Run: java com.javatpoint.core.Simple
The output will be Hello subpackage. How to send the class file to another directory or drive? There is a scenario, I want to put the class file of A.java source file in classes folder of c: drive. For example:
To Compile:
To Run:
To run this program from e: directory, you need to set classpath of the directory where the class file resides.
The -classpath switch can be used with javac and java tool. To run this program from e: directory, you can use -classpath switch of java that tells where to look for class file. For example:
The output will be: Welcome to package.