Jump to content
  • Advertisement
Sign in to follow this  
jake2431

[java] Can't compile hello world!

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I just picked up a book on Java recently and have just today tried using it. I downloaded the J2SE SDK and installed it. The compiler is working because if I go to the command prompt and type javac it gives me compiler info. Well I went to notepad and typed the code public class Hello { public static void main (String[] args) { System.out.printIn("Hello World"); } } and saved it as Hello.java. Then I went to the command prompt, went to the folder "c:\myjava\" where I saved the file and tyoed javac Hello.java and it gave me one error saying that it didn't understand the symbol "." after "out". I figured that maybe it was because the file still had the .txt extension (i.e. Hello.java.txt) so in the command prompt I typed "ren Hello.java.txt Hello.java" and got the same error. It's not even showing the java icon for the .java files :( . By the looks of the book this should work fine. Can anyone help me? -Jake [Edited by - jake2431 on March 14, 2005 9:23:50 PM]

Share this post


Link to post
Share on other sites
Advertisement
Rating+ for you! Ahh.... now I feel stupid. Lowercase L's and Uppercase I's always confuse me in some fonts, but I still should have thought of that. For some reason I was thinking that the command was print in and didn't consider print line. Well, thanks alot though. Any idea why when I save as .java it doesn't give a java Icon it just gives the notepad icon. The reason I ask is because in the book his files have a icon. Maybe it's because of the IDE he is using and I'm not, but it seems like it would display after installing all the java stuff. Thansk again for the help.

-Jake

Edit: Now even the compiled file doesn't have an icon, but it did compile! Yes, I'm so excited. I love learning new stuff.

Share this post


Link to post
Share on other sites
You need to go to folder options in the settings tab and click on the file settings (or something like that :-) Tab, find the .java extention and click the change button. Then a dialog should come up, click change icon and locate the icon that you would like .java files to display. then click OK a lot of times, hope that helped ( i use Windows 98).

Share this post


Link to post
Share on other sites
I couldn't figure it out, thanks for the help though. I am running WinXP so it may be different. The closest thing I could find was the folder options > file types, but there isn't even a .java file type named.
-Jake

Share this post


Link to post
Share on other sites
Quote:
Original post by jake2431
I couldn't figure it out, thanks for the help though. I am running WinXP so it may be different. The closest thing I could find was the folder options > file types, but there isn't even a .java file type named.

Files, such as .java or any other, are delegated icons solely on the program used to open them. Since you're working from a command line instead of an IDE, .java files are naturally associated with Notepad. If you want to change this, you need to install an IDE - such as Textpad, Eclipse, MSVC will append .java files with the evil J# icon, *insert other IDE here*. The IDE installation will usually associate these files for you. However, if you already have an IDE, or just want to open .java files with a different program, do the following :
 - Highlight and right-click on any java file
- In the pop-up menu, choose "Open-With"
- Select the .exe (the .exe itself, shortcuts won't work) and click "Ok", or "Open"
- Click the box labeled "Always open with this program"
- Exit

All .java files should now be associated with whatever program you chose, and if there is no "special" .java icon, they will now have the program's default icon.

*Disclaimer : There is probably a generic method for changing icons ... but the above works if that's what you want.
Quote:
Edit: Now even the compiled file doesn't have an icon, but it did compile! Yes, I'm so excited. I love learning new stuff.

Heh, that's good. Java is good stuff. As for the .class file not having an icon, that's normal. You can't edit the contents so there's no point in opening them.

Share this post


Link to post
Share on other sites
Thanks for everyone's help. So I guess my assumption that it may be his IDE was correct. Yeah I love the open with option; I hate when computers don't have that (like some at my school. I hate having to go to the exe and open from there). The reason I didn't know if it should have a icon automatically is because of my experience with HTML and javascript. You know when you save as .js it automatically comes up with the icon for it even though I only open it with notepad. I just never click the always open with this program thing. Thanks again for all the help guys, the gamedev forums are awesome for finding knowledgeable people who are willing to help. Now I have to work on a final project for Life Drawing and then I will resume coding.

-Jake

Share this post


Link to post
Share on other sites
Ummm. I have another question. The book I am using uses JPadPro as its IDE. I know this question will be highly opinion based, but what is the best free Java IDE. By free I mean one that is completly free; as in you can make a program and sell it if you want. Any suggestions?

Share this post


Link to post
Share on other sites
Eclipse, JBuilder and JCreator are my favorites with Eclipse probably being my very favorite. I like Eclipse for its features, JBuilder for its simplicity and JCreator for its speed. All of which are free (or have a free version). I don't think the IDE you use to write code has anything to do with the licensing issues of your finished application - the IDE just simplifies the organization/writing of source files, the compilation and possibly the debugging. Correct me if I'm wrong.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!