Q&A for How to Compile & Run Java Program Using Command Prompt

Return to Full Article

Search
Add New Question
  • Question
    What would I do if I type in the Java filename.java and it is not running? The code written in Notepad is correct.
    Community Answer
    It is okay. You have to write for compiling : javac filename.java and for running: just filename.
  • Question
    How can I compile using CMD?
    Community Answer
    Once you are in the correct directory, you can compile the program by typing "javac filename.java" into the command line and pressing enter.
  • Question
    How can I hack a computer using the command prompt?
    Community Answer
    You can't without installing other things. CMD is NOT for hacking and should never be used for it.
  • Question
    What if when I type the direction of my file, for example "C:\Users\javaproject," the CMD replied this to me :(C:\Users\javaproject is not recognized as an internal command operable program or batch file)?
    Community Answer
    After you defined the directory, you have to do the following: 1) Copy : C:\Program Files\Java\jdkvesion\bin 2) Specify the jdk version 3) Copy the path then you have to write inside cmd set path="C:\Program Files\Java\jdk1.8.0_91\bin"
  • Question
    How do I compile my Java program if the command javac is not being recognized in the command prompt? What should I do?
    Living Concrete
    Top Answerer
    This means that you either do not have JDK installed or you do not have the javac binary added to your PATH environment variable. Try reinstalling the JDK or looking up how to add javac to your PATH environment variable for your operating system.
  • Question
    What does it mean when the command prompt says "javac"?
    Community Answer
    "javac" is short for Java Compiler. It's the service that compiles your Java into more computer readable code.
  • Question
    What can I do if filename.java is not working?
    Community Answer
    Make sure that you are replacing "filename" with the actual name of your .java file. If it is still not working, there was an error in your code, check your syntax and try again.
  • Question
    When I execute the java file after compiling, I see a message that says, "Error: couldn't find or load main class test.java." How do I fix it?
    Isaac keeling
    Community Answer
    I would guess you have been trying to run with "java test.java," whereas you should actually use "java test." This is for two reasons: firstly, test.java would refer to the java source file when you need the (compiled) class itself; secondly, the "java" command only wants the class name, not the file name.
  • Question
    How do I run a java program when the command prompt shows that the saved file is not found?
    Community Answer
    Either you don't have java jdk on your system or the file does not exist.
  • Question
    What command will be given at the command prompt instead of "CD desktop" if I had saved my Java programs in a folder not present on the desktop?
    Community Answer
    This depends entirely upon where you saved your Java programs. Assume you saved the Java programs in C:\temp\Java (replace with whatever directory you saved your files to); you'd enter the command CD C:\temp\Java and then use DIR to list contents of the folder. If any component of the folder path has one or more non alpha-numeric characters (i.e. space), you must use a double quote to begin the path name, i.e. CD "C:\temp\Java Programs".
  • Question
    How to delete Java?
    iMetroLive
    Community Answer
    Click Start, point to Settings, and then click the Control Panel. In the Control Panel, double-click the Add/Remove Programs. On the Install/Uninstall tab, click the Java version you want to uninstall, and then click Add/Remove. When you are prompted to continue with the Uninstall, click Yes.
  • Question
    What do I do if my Java program made in Notepad isn't executing?
    iMetroLive
    Community Answer
    Open the notepad and write a Java program into it. Save the Java program by using the class name followed by . java extension. Open the CMD, type the commands and run the Java program.
Ask a Question

      Return to Full Article