• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I use the official Java Compiler  RSS feed

 
Randolph Brisbon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading the book Head First Java. And I wanted to know how to compile java code with the official java compiler. I already installed it but it's very hard for me to use. In the book it doesn't say how to use the compiler.
 
Kr Manish
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.skylit.com/javamethods/faqs/javaindos.html

This should guide you. Please come back if you find any problems in any of the steps.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at our beginners' FAQ, especially No 1 and No 2, and this FAQ, too.

Remember you must set a PATH somehow.
It is very unlikely you will have to set a CLASSPATH, so don't do anything with your system CLASSPATH.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Randolph Brisbon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Have a look at our beginners' FAQ, especially No 1 and No 2, and this FAQ, too.

Remember you must set a PATH somehow.
It is very unlikely you will have to set a CLASSPATH, so don't do anything with your system CLASSPATH.


I can get the folder to come up but I can't get the file to compile.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just saying "I can't get it to compile" doesn't really help us understand the problem. what are you doing exactly, and what exactly IS happening? unless you tell us that, we really can't give you any advice.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read: ItDoesntWorkIsUseless. It will help you get better and quicker answers here on the Ranch.
 
Randolph Brisbon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I typed up the example code into notepad. Then I started cmd it loaded the folder i put the java code in (My Documents) but then when I tried to type the file name it said something about the file not being there.

If that's not enough I'll try to post some pictures.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this Hello World tutorial. It explains in very small steps what to do to write, compile and run your first Java program.

Have a look at the page Common Problems (and Their Solutions) of that tutorial. It most likely describes exactly what your problem is and how to solve it.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randolph Brisbon wrote:I typed up the example code into notepad. Then I started cmd it loaded the folder i put the java code in (My Documents) but then when I tried to type the file name it said something about the file not being there.

this isn't really the level of details we need. I don't know what "it loaded the folder" means. I assume that "i put the java code in (My Documents)" means that you saved your *.java file to something like "C:\Documents and Settings\fbr1917\My Documents".

did you cd into that directory from the command prompt?

what do you mean by "i tried to type the file name?" did you just type the file name, or did you try running the compiler - something like "javac MyClass.java"? If you did the latter, what - EXACTLY - was the error message? The exact phrase really, truly does tell you a lot about what the problem is. Vague descriptions of the "it said something about..." really don't tell us anything. Or rather, they leave the possibility of it being any of a half dozen issues, and people don't want to waste their time guessing what the problem MIGHT be.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a good idea to open the command line, write
mkdir java
cd java
or similar. Now you can get at your Java™ work simply by writing
cd java
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!