Thursday, July 30, 2009

How do I make a file a Java file?

I just started a Java Programming Course online and it gave us example programs that we were supposed to modify. I opened and made the modifications but they only let me save them as text files and the only way to compile them is if they are "Java" files. Can someone tell me how to fix this?

How do I make a file a Java file?
Saving the file won't compile the file, that only saves the uncompiled code to disk. You might want to read a Java tutorial on the Sun website (http://java.sun.com/docs/books/tutorial/... The example is the typical "hello world" application but it gives you the basic idea of how to compile a simple program. Now if you start to get a bit more serious about coding, consider using a Java IDE. I use WebLogic Workshop (http://www.bea.com) but it isn't exactly a free IDE. Some developers here use the free Eclipse IDE (http://www.eclipse.org) but I can't say that I've used it. JEdit is another that some developers swear by but I haven't used it.





If you find that you need to continually rebuild a project, consider looking into using Ant (http://ant.apache.org/) to create a controlled build environment. I wouldn't necessarily jump right into this though if you are only doing fairly simple programs. The learning curve isn't too steep though so check it out and see if you want to implement.
Reply:I think you must be using NOTEPAD for saving your java file.. What you can do then is as you SAVE it, it will ask you for a file name. And instead of saving as say HelloWorld.java, save it as "HelloWorld.java" i.e. with quotes or else notepad will rename it automatically as HelloWorld.java.txt which might be your present case.





Hope this helps..
Reply:What you really want to do is to download Sun's Java SDK 1.4 or higher, this comes with a Java compiler. For serious Java development use an IDE (integrated development environment) a great free on is Eclipse.


No comments:

Post a Comment