how to run java applications using the windows command prompt. julian falasca may 11 th, 2010 engl...
TRANSCRIPT
![Page 1: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/1.jpg)
How to Run Java Applications using the Windows Command Prompt.
Julian FalascaMay 11th, 2010
ENGL 393
![Page 2: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/2.jpg)
Introduction
• Purpose: Most IS courses don’t touch this topic.
• Target Audience: Students already familiar with Java programming. (CMSC and IS majors)
• When to Use: On the job.• Safety Information: Don’t get too excited.
![Page 3: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/3.jpg)
Materials Needed
• At least 1 valid java source file. (HelloWorld.java)– Must know where this file is located.
• Java Development Kit (JDK) already installed.– http://java.sun.com/javase/downloads/index.jsp
![Page 4: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/4.jpg)
Step 1• Click on Start, Programs, Accessories, and
select Command Prompt.
![Page 5: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/5.jpg)
Example Command Prompt
![Page 6: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/6.jpg)
Step 2
• This example uses a java file which is located:D:\Workspace\HelloWorld.java
• Type d: and press enter.– This command changes directories to the D drive.
![Page 7: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/7.jpg)
Example Command Prompt
![Page 8: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/8.jpg)
Step 3
• Type cd Workspace and press enter.– This takes you into the Workspace directory.
![Page 9: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/9.jpg)
Example Command Prompt
![Page 10: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/10.jpg)
Step 4
• Type dir and press enter.• This displays a list of files in the current directory.– Confirm that HelloWorld.java is in the list.
![Page 11: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/11.jpg)
Example Command Prompt
![Page 12: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/12.jpg)
Step 5
• Type javac HelloWorld.java and press enter.– This compiles the file, allowing you to run it.• A new file has been created named HelloWorld.class.
![Page 13: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/13.jpg)
Example Command Prompt
![Page 14: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/14.jpg)
Step 6
• Type java HelloWorld and press enter.– The Java application will run.
![Page 15: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/15.jpg)
Example Command Prompt
![Page 16: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/16.jpg)
Conclusion
• Warranty Information: N/A• Technical Support: Lookup commands on google.• FAQs: – Why do I get the error “javac command not
recognized”?• Most likely you have not installed the JDK correctly.
– How do I go to the previous directory?• Type cd .. and press enter.
![Page 17: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/17.jpg)
Conclusion ContinuedProblem Cause Solution
When compiling you get the following error: Class names, ‘HelloWorld’, are
only accepted if annotation processing is explicitly
requested.
You typed javac HelloWorld You must include the file extension when compiling. Type javac HelloWorld.java
When running the application you get the
following error: Exception in thread “main”
java.lang.NoClassDefFoundError: HellowWorld/class
You typed java HelloWorld.class
You cannot include the extension when running.
Type java HelloWorld
![Page 18: How to Run Java Applications using the Windows Command Prompt. Julian Falasca May 11 th, 2010 ENGL 393](https://reader035.vdocuments.mx/reader035/viewer/2022062519/5697bfac1a28abf838c9b841/html5/thumbnails/18.jpg)
Questions?