Results 1 to 12 of 12
  1. #1
    AMIT TAYADE is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Default cannot read file while compiling!!!

    hi,
    i had just started with java.
    while compiling, error is that it cannot read file.
    i has saved file with .java extension.

    i have installed sdk2toolkit & i have done all possible things to set path of bin folder(via cmd & using environment variable).

    please reply!!!!!!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default

    Please copy and paste here full text of console showing commandline and error message.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by AMIT TAYADE View Post
    hi,
    i had just started with java.
    while compiling, error is that it cannot read file.
    i has saved file with .java extension.

    i have installed sdk2toolkit & i have done all possible things to set path of bin folder(via cmd & using environment variable).

    please reply!!!!!!
    You should explain well about your question.

    What error message you get? Better to send it here to see all other members who are trying to solve.\

  4. #4
    udayadas's Avatar
    udayadas is offline Member
    Join Date
    Aug 2008
    Posts
    22
    Rep Power
    0

    Default

    Hi,

    I have seen this problem occurring many times.At times our source files gets saved with name XXX.java.txt instead of being XXX.java if you are using notepad as your editor.You will not even realize it if your files extensions are not shwing.

    Assuming that you are using an ASCII plain text editor like note pad to write your java programme...make sure that while saving the file you enclose the name within double quotes...like "XXX.java".

    Hopefully that will solve the issue..unless you are not compiling the java file from a location where it actually does not exist.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Actually in most of the case files saved as *.java.txt, the file extension *.java is not registered in the system. So the system automatically directed to the *.txt file extension, when you are working with the notepad.

    In that case you no need to use double quotes. If the *.java file extension is not registered you can solve it using double quotes as you mentioned.

  6. #6
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by udayadas View Post
    if you are using notepad as your editor.
    And the obvious solution is to not use Notepad.

    real men use vi or emacs. If you are not ready for that, use Eclipse or Netbeans. Problem solved.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    As a Java newbie better to use Notepad, and emacs for linux users. Later on better to move with an advance Java IDE like, Notepad. fishtoprecords, I'm confusing that why are you advice not to use Notepad.....

  8. #8
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    fishtoprecords, I'm confusing that why are you advice not to use Notepad.....
    Because of its well known, but undocumented 'feature' of converting what you think if MyClass.java into MyClass.java.txt

    There are tons of free simple editors for all known operating systems that are not as broken as notepad.

    For years, I've used VIM on windows, aka vi

    And if you like graphical stuff, there is gvim

    Notepad is evil. There are hundreds of thousands of better programs to do trivial editing

    I know that several of the regulars here recommend trivial editors and manual compilation, but I've found that using something like NetBeans is much easier to get folks started. Getting the classpath right, getting the options to the compiler, etc. are things that get in the way of writing an "hello world" program.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by fishtoprecords View Post
    Because of its well known, but undocumented 'feature' of converting what you think if MyClass.java into MyClass.java.txt
    Yes, it's true. But why I suggest the Notepad is, users can keep in touch with basis like keywords, naming conventions and so on.

    Quote Originally Posted by fishtoprecords View Post
    There are tons of free simple editors for all known operating systems that are not as broken as notepad.
    Yep, emacs is one of the best editor I've use in the past.

    Quote Originally Posted by fishtoprecords View Post
    I know that several of the regulars here recommend trivial editors and manual compilation, but I've found that using something like NetBeans is much easier to get folks started. Getting the classpath right, getting the options to the compiler, etc. are things that get in the way of writing an "hello world" program.
    But the issue is, newbie has to learn about Java as well as how to use the IDE. Just see our Java IDE forums. Most of the newbie wired with how to use some functionality with learning Java.

  10. #10
    udayadas's Avatar
    udayadas is offline Member
    Join Date
    Aug 2008
    Posts
    22
    Rep Power
    0

    Default

    If I were a fresher to Java...I would choose a editor which does nothing for me apart from allowing me to write on it and save it(like notepad).That will brush up my skills.

  11. #11
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Yep, emacs is one of the best editor I've use in the past.
    Oh, you are one of *them*

    folks tend to either love or hate emacs. I never saw any reason to spend the time learning it, and it has a non-trivial learning curve.

    We'll have to agree to disagree. I've found Netbeans to be trivial to download, install and then you do a "file -> new -> java -> main class"
    and you are ready to rock.

    If you want something easy to get started in, use Smalltalk

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by fishtoprecords View Post
    Oh, you are one of *them*
    Ya, I really like it. Some times I'm working on Java without an IDE, actually without using NetBeans. That's to brush my skills in different way. In that case I simply logging to my linux machine and the emacs editor. :)

    You are right, it's not difficult to create a main class and work on NetBeans. But not just that only, most of the people doesn't know how to handle command line arguments. Some doesn't know how to attach an additional jar files. How to working with multiple project as a single application...... and many more.

Similar Threads

  1. Read file from URL and save to FTP
    By nitinmukesh in forum Networking
    Replies: 6
    Last Post: 06-03-2012, 08:45 PM
  2. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM
  3. Read file
    By tajinvillage in forum Threads and Synchronization
    Replies: 0
    Last Post: 01-29-2008, 09:10 AM
  4. Poblem in Compiling a c++ file from a java program...
    By Amit Kr. Mishra in forum New To Java
    Replies: 0
    Last Post: 11-06-2007, 10:41 AM
  5. read txt file
    By sureshsri1981 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-05-2007, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •