aspose file tools*
The moose likes Beginning Java and the fly likes SOURCE FILES ARE NOT .JAVA FILES Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SOURCE FILES ARE NOT .JAVA FILES" Watch "SOURCE FILES ARE NOT .JAVA FILES" New topic
Author

SOURCE FILES ARE NOT .JAVA FILES

Jay Jay King
Greenhorn

Joined: Jul 25, 2004
Posts: 1
Why does Java take a long protocol of having the programmer to compile in text editor like Notepad before getting to DOS to compile, and run. Besides, most source files saved in NOTEPAD do not become .java until I tried DOS Edit. Is there a special procedure which can make sourcefiles hava .java. NoteL I saved my source files as .java in Notepad


Java is very interesting and fun.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Make sure, when you're saving a file in Notepad, that the "File type" dropdown box is set to "All Files." If it's set to ".txt" files, I believe your file will be named "YourFile.java.txt". If you set that drop down to "All Files," I believe you can avoid this problem.

Of course, there are other editors out there that are much nicer than the vanilla notepad that comes with Windows. I like Ultra-Edit, myself, but everyone has a preference.


SCJP Tipline, etc.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The other option is to put " " around your name like "source.java". Then you don't have to worry about the file-type drop down at all.


GenRocket - Experts at Building Test Data
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

get the free 'scite'-editor which has syntaxhighlightening, linenumbers and other useful stuff.

Delete notepad today.
It was developed by Bill Gates himself and nobody at microsoft has the **** to kick it out.

Hm. It's only a guess - but my only explanation.


http://home.arcor.de/hirnstrom/bewerbung
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Stefan Wagner:
It was developed by Bill Gates himself and nobody at microsoft has the **** to kick it out.


Oh, really? I didn't know that Notepad in the MS Windows was developerd by Bill Gates... Nice to know it...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Sadanand Murthy
Ranch Hand

Joined: Nov 26, 2003
Posts: 382
Originally posted by Jay Jay King:
Why does Java take a long protocol of having the programmer to compile in text editor like Notepad before getting to DOS to compile, and run. Besides, most source files saved in NOTEPAD do not become .java until I tried DOS Edit. Is there a special procedure which can make sourcefiles hava .java. NoteL I saved my source files as .java in Notepad


Others have given very good advice. My post is to address your misunderstanding that I've boldfaced in the above quote. You do not, generally, compile in the text editor and you certainly cannot do that in Notepad (although some editors do provide you with such a capability). You merely write the program in a text editor.


Ever Existing, Ever Conscious, Ever-new Bliss
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11402
    
  16

To expand on Sadanand's point... How else are you going to create the .java file?

To back up a little, there are three main steps in creating and running a java program.

1) write the source file
2) compile the source file into a .class file
3) execute the class file

These are gross simplifications, but the basics are correct. So you ask "why write the file in a text editor?"

I'd answer that with "how ELSE are you going to create the source file?" And save it? and modify it? Java doesn't care HOW this file is created - you can use ANY editing tool you want. if you want to write an assembly program that directly connects to the hard disk and writes the file byte by byte - go for it. as long as it follows certain rules (named .java, the public class name matches the file name, etc) you can create this file any way you want.

once the file is created, you then proceed to steps 2 and 3. There are some tools that let you do all 3 steps within the tool - they integrate the text editor, compiler and run-time environment (and are called Integrated Development Environments, or IDEs). They may do fancy things like paren-mathcing, finding syntax errors, etc. But those are all just bells and whistles.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
K. Joshua Chi
Greenhorn

Joined: Jul 31, 2004
Posts: 10
Thanks you all for sending in lovely replys. I tried the " " method/.all files method and it worked. I might not be replying with my original ID as JAY JAY King, this is becos I lost my password. Thanks


Jay Jay achieves!
Jack Kay
Ranch Hand

Joined: Aug 01, 2004
Posts: 62
Originally posted by Stefan Wagner:
Delete notepad today.
It was developed by Bill Gates himself and nobody at microsoft has the **** to kick it out.


I'm offended
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SOURCE FILES ARE NOT .JAVA FILES