Java and the Command Line - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Java and the Command Line

Description:

Basic Unix commands. 15-110. 2. Java PATH variable ... Read the Basic Unix Commands.pdf document. Section 1.1. 15-110. 9. Homework ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 10
Provided by: csC76
Category:
Tags: command | commands | java | line | unix

less

Transcript and Presenter's Notes

Title: Java and the Command Line


1
Java and the Command Line
  • Java PATH variable
  • Compiling a program
  • Basic Unix commands

2
Java PATH variable
  • Install Java and find out the exact location of
    the jdk file
  • C\Program Files\Java
  • Dont need to do this if you have a Mac!
  • Determine the version of Java installed
  • jdk1.5.0_6
  • jdk1.5.0_12
  • jdk1.6.0
  • Your PATH is
  • C\Program Files\Java\ jdk1.5.0_12\bin

3
Java PATH variable (cont)
  • You will need to set the PATH if you get an error
    saying something like javac is not a
    recognizable command
  • The PATH is needed so you can invoke the Java
    compiler from any location (subdirectory) in your
    computer.
  • Read corresponding document on how to change the
    PATH variable in your computer.
  • Java Troubleshooting.pdf

4
Opening the Console Window
  • Mac users
  • open the TERMINAL application
  • PC users
  • go to START
  • select PROGRAMS
  • select ACCESSORIES
  • select COMMAND PROMPT

5
Compiling a Java program
  • From the command window (console) type
  • javac filename.java
  • This will compile your program creating the
    corresponding .class file. Or it will create
    error messages.
  • The source file (example.java) and its
    corresponding class file (example.class) will be
    located in the same folder (subdirectory).

6
Executing a Java application
  • From the command window (console) type
  • java filename
  • java filename.class
  • You can compile several files at once
  • javac file1.java file2.java file3.java
  • Only one of those have a main() method
  • Lets assume is file2
  • Execute the application by typing
  • java file2

7
Basic Unix commands
  • ls displays the contents of the directory
    (folder)
  • dir command in Windows
  • rm filename deletes a file
  • del filename command in Windows
  • cd .. changes directories moving up one level
  • cd moves to the home directory
  • cd directory moves down to that directory

8
Readings
  • Read the Java Troubleshooting.pdf document to set
    up the PATH variable.
  • Read the Basic Unix Commands.pdf document.
  • Section 1.1

9
Homework
  • Lab 07 is this Monday the 12th
Write a Comment
User Comments (0)
About PowerShow.com