• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SOURCE FILES ARE NOT .JAVA FILES

 
Jay Jay King
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
K. Joshua Chi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jack Kay
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic