My professor asked us to create a Java program that would be able to run in command prompt but could also be opened using NetBeans.
The program is about using the di
Follow these steps (code examples are just examples, you will need to tweak some for your setup):
Set your JAVA_HOME to the directory where the JDK is installed.
set JAVA_HOME="c:\Program Files\Java\jre1.6.0_12"
Set your PATH to include the bin
directory in JAVA_HOME.
set PATH=%PATH%:%JAVA_HOME%\bin
Change to the root directory of your source code. If you have declared your code to be in packages, this is the root directory of your package structure. If not, this is the directory that contains your .java files:
cd c:\My\Source\Directory
Execute javac with your Java files as the argument:
javac Class1.java Class2.java
(Assuming everything compiles correctly) Execute java
with the name of the class containing your main method as the argument (if you included package declarations, then your class name is fully-qualified, meaning it should include the package name before the class name, with a '.' separating the package name from the class name):
java Main
You will have a build directory inside your project. Navigate to it. Next open the classes folder.
Now here open the terminal and run java x/y
where x is the name of the package your main class is in and y is the name of that java file