R
R
Ro Gry2021-09-22 12:30:38
Java
Ro Gry, 2021-09-22 12:30:38

"This document cannot be saved with a '.java' extension at the end of the name. The '.rtf' extension is required." on macOS. What to do?

Hello!

Trying to save a file on a macbook that I created in a simple TextEdit with the following code:

public class HelloWorld {
    public static void main(String args[]) {
        System.out.println("Hello World!");
    }
}


To which a window pops up for me with the following text: It
is impossible to save this document with the “.java” extension at the end of the name. Requires ".rtf" extension.

What should I do in this case and what is my mistake?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2021-09-22
@rogry_soft

Use an editor designed for editing code, in the case of java, it is better to use an IDE right away

O
Oleg, 2021-09-22
@402d

It won't work out. Source texts for any language are plain text files.
That is text without formatting. The problem is that TextEdit offers
richer formats.
614afb1657a3e391672413.png
In all formats (in which you can save) there will be garbage, which then will not allow the code to work.
Not everyone needs special IDEs, in case of fixing the file, I can sometimes recommend CotEditor (16 megabytes).

P
Parad1so, 2021-09-26
@Parad1so

TextEdit is not an analogue of notepad in windows
, it is rather a simplified analogue of Word
. You need a simple text editor like vim, Sublime, etc.,
or a normal IDE that will do all the nonsense for you, including compilation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question