• Post Reply Bookmark Topic Watch Topic
  • New Topic

Terminal Error  RSS feed

 
Renne Bautista
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone. So after getting advice from a friend and also the book I'm reading, to not start off using an IDE, I'm now using the terminal with JDK 7.

I wrote:


I wrote this just to make sure I had everything running correctly, in terms of paths and such. This is what the terminal comes back with:


I don't see why there should be any errors with the code. Can anyone give me an idea of what I'm doing wrong or point me in the right direction?

-Renne
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably are using a word processor to put in the text. It has put "smart quotes" in instead of simple straight quotes.

Use a text editor like vi (in Linux/Mac?) or Notepad (in Windows). There are other text-friendly editors like Notepad++ that you can use too.
 
Renne Bautista
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:You probably are using a word processor to put in the text. It has put "smart quotes" in instead of simple straight quotes.

Use a text editor like vi (in Linux/Mac?) or Notepad (in Windows). There are other text-friendly editors like Notepad++ that you can use too.



I'm using TextEdit on OSX and I switched it to Plain Text Format. From my understanding TextEdit shouldn't give me an issue with that.

But I will certainly try the recommendations you made. Thank You!!
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're using OS X:
user friendly: TextWrangler
advanced: vim, emacs (these are installed already, so you can type in terminal "man vim" to see all available commands, as well as "man emacs" - "man" stands for manual)
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:You probably are using a word processor to put in the text. It has put "smart quotes" in instead of simple straight quotes. . . .
Definitely. I looked up \8220 but that is in decimal numbers. When you convert it to hex you get \u201c, and that looks like this: “ \8221 is \u201d which is right‑quote: ”
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote: . . . Notepad (in Windows). . . .
There is only one thing worse than having to use Windows, and that is using Notepad. The other thing KS suggested, Notepad++, however, is an excellent programmer's editor. It appears only to work on Windows, so I searched for Notepad++ on OS/X and found this.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:It appears only to work on Windows, so I searched for Notepad++ on OS/X

About "TextWrangler" on OS X need to thing the same as about "Notepad++" on windows.
http://www.barebones.com/products/textwrangler/
 
Renne Bautista
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I installed TextWrangler and Sublime Text 2, used the same code from above and saved it as a .java file. It fixed the errors I was getting, but now it is giving me this one error back:

 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Renne Bautista wrote:So I installed TextWrangler and Sublime Text 2, used the same code from above and saved it as a .java file. But I get the same 4 errors when I try to compile it
Don't copy/paste the code - rewrite it and see what happens then.
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error you are seeing is because you have a public class which is in a file with a different name.
If the class is public put it in a file with exactly the same name (+.java).
 
Renne Bautista
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked! I had to do both. Started a new file with the same name as the class and rewrote the code instead of copy and pasting. It compiled and created a .class file!

Thank you for all the help, everyone!!

One more question, should the terminal print out a line saying 'Hello, World' or does it just compile and create a .class file?
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>should the terminal print out a line saying 'Hello, World' or does it just compile and create a .class file?

There is one command for compiling, and another for running.
I'm presuming you are executing javac right now.

The javac command compiles your java code and creates your .class files
The java command runs the compiled .class files, which in this case will printout out "Hello World"


 
Renne Bautista
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YES!! It worked. Thank you!! I just found a site that helps with using Java and the OS X terminal, too.

Much appreciated everyone!!
 
Campbell Ritchie
Marshal
Posts: 56530
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!