Jump to content

  •  

Photo
- - - - -

How to: Compile and run a .java file in OS X in the Terminal

OS X Java

  • Please log in to reply
No replies to this topic

#1 Wilson18

Wilson18

    Administrator

  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 08 October 2014 - 10:05 PM

Compiling and Running a .java file on OS X

The first thing you will need to do is to open the Terminal. You can do this by following the images below.

post-1-0-67534800-1412804211.png

Once you have opened terminal, you will need to navigate to the directory you have stored your .java file. You can use this by using the cd command showing in the screenshot below. You can then view everything in that directory by typing the ls command.

 

post-1-0-34406300-1412804468.png

The final thing is to compile and run our program. The command for this is as follows

javac Classname.java

to run the program, we type in

java Classname

You can see a full example in the image below.

post-1-0-56042500-1412804727.png


List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+






Also tagged with one or more of these keywords: OS X, Java