Как сохранить файл в intellij idea

от admin

Save and revert changes

IntelliJ IDEA automatically saves changes that you make in your files. Saving is triggered by various events, such as compiling, running, debugging, performing version control operations, closing a file or a project, or quitting the IDE. Saving files can be also triggered by third-party plugins.

Most of the events that trigger auto-save are predefined and cannot be configured, but you can be sure that changes will not be lost and you can find all of them in local history.

Configure autosave behavior

In the Settings dialog ( Ctrl+Alt+S ), select Appearance & Behavior | System Settings .

Under Autosave , configure the following options:

Save files when switching to a different application or a built-in terminal : Save all modified files when you switch from IntelliJ IDEA to a different application.

Save files if the IDE is idle for N seconds : Save all modified files at regular time intervals.

Apply the changes and close the dialog.

Mark files with unsaved changes

You can mark unsaved files with an asterisk (*) on the file tab:

In the Settings dialog ( Ctrl+Alt+S ), select Editor | General | Editor Tabs .

Select the Mark modified (*) checkbox.

Apply the changes and close the dialog.

After that, the tab of the file in which you have unsaved changes will be marked with an asterisk.

If you use version control integration, names of all modified files will be also marked with a dedicated color on the file tab and in the Project tool window.

Save changes manually

You can always save your changes manually:

Press Ctrl+S or select File | Save All from the main menu.

Trigger actions when saving changes

In IntelliJ IDEA, you can configure the actions that will be triggered every time your modified files are saved.

In the Settings dialog ( Ctrl+Alt+S ), select Tools | Actions on Save .

Select the checkboxes next to the actions that you want to trigger on save:

Reformat code: reformat your code according to your current code style settings.

Optimize imports: remove unused imports and organize import statements according to your current code style settings.

Rearrange code: reorder code elements according to your current code style settings.

Run code cleanup: batch-apply quick-fixes from code cleanup inspections in the current inspection profile.

Update copyright notice: update information in copyright notices in project files.

Run eslint —fix: (IntelliJ IDEA Ultimate) fix the detected problems with ESlint.

Enabling this option also enables Run eslint —fix on save.

Upload to default server: (IntelliJ IDEA Ultimate) upload modified files to your default deployment server.

Build project: compile all the classes inside your build target and place them inside the output directory.

Enabling this option also enables Build project automatically.

For some actions, you can configure the settings more precisely. To do so, hover the mouse pointer over an action and click the configuration link.

For example, for code reformatting, you can specify files and folders that you don’t want to change. Hover the mouse pointer over the action and click Configure scope to exclude specific files and folders from reformatting.

You can also select whether to reformat the whole file or only modified lines.

Apply the changes and close the dialog.

Once the necessary actions are enabled, they will be automatically triggered on every save (autosave, explicit save invoked with Ctrl+S or by selecting File | Save All ) as you work with your project.

Revert changes

For most recent changes, including refactorings, press Ctrl+Z or choose Edit | Undo from the menu.

For a more detailed view of past changes, use Local History.

For the most robust tracking of all changes, use a version control system.

Как сохранить файл в intellij idea

Цветовое представление клавиш на клавиатуре

Обозначение кнопок мыши в таблице:

Левая кнопка Правая кнопка Двойной клик Колесико

— Имеется дополнительная информация во всплывающей подсказке

Управлять столбцами таблицы можно с помощью горячих клавиш:

Alt ( 1 .. 5 ) — Скрыть/показать столбец 1 — 5; Alt 0 — Показать все столбцы

How to create a .jar file or export JAR in IntelliJ IDEA (like Eclipse Java archive export)? [duplicate]

I was using IntelliJ IDEA IDE. I want to create a JAR file from Java compiled class files. But I didn’t find a command or file.

How to create a JAR file (like it is done in Eclipse)?

informatik01's user avatar

sungkwangsong's user avatar

3 Answers 3

For Intellij IDEA version 11.0.2

File | Project Structure | Artifacts then you should press alt+insert or click the plus icon and create new artifact choose —> jar —> From modules with dependencies.

Next goto Build | Build artifacts —> choose your artifact.

Как сохранить файл в intellij idea

IntelliJ IDEA provides the following main ways to upload project files and folders to deployment servers:

Manually , at any time through a menu command.

Automatically , every time a file is updated, or before starting a debugging session, or during a commit to your version control system.

For downloading files and folders, IntelliJ IDEA supports only the manual mode.

IntelliJ IDEA shows the logs in the File Transfer tool window ( View | Tool Windows | File Transfer ).

File Transfer tool window

Upload a file or folder manually

In the Project tool window, right-click a file or folder, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list.

If the default server or server group is appointed, you can also select Upload to <default deployment server or server group> .

Upload locally changed files

Switch to the Local Changes view to view the locally changed files.

Right-click a file, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list. If the default server or server group group is appointed, you can also select Upload to <default deployment server or server group> .

Upload files after synchronizing with a VCS repository

Synchronize the contents of your local files with the VCS repository by pressing Ctrl+T or selecting VCS | <VCS> | Update from the main menu.

Switch to the Update Info tab of the Version Control tool window Alt+9 .

Right-click a file, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list. If the default server or server group is appointed, you can also select Upload to <default deployment server or server group> .

Читать:
Что можно написать на java
Upload checked-in files immediately after commit

Start checking in your changes.

In the After Commit area, choose the target server or server group from the Upload files to list. Choose one of the existing configurations or create a new one: click and configure access to the relevant server or set up a server group in the Deployment dialog that opens.

To have your selection applied automatically in the future, select the Always use selected server or group of servers checkbox.

Configure automatic upload of changed files to the default server or server group

IntelliJ IDEA considers a local file changed as soon as it is saved either automatically or manually ( File | Save All or Ctrl+S ), see Save and revert changes. Changed files can be automatically uploaded only to the default deployment server.

Open the Options dialog by doing one of the following:

From the main menu, choose Tools | Deployment | Options .

In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Build, Execution, Deployment | Deployment | Options .

From the Upload changed files automatically to the default server list, choose when you want IntelliJ IDEA to upload changed files:

To upload any manually or automatically saved file, choose Always .

To upload only manually saved files, choose On explicit save action .

To suppress automatic upload, choose Never .

If you enabled automatic upload, optionally configure the scope it should apply to:

Select Skip external changes to exclude local changes that were made using a third-party tool (a VCS, a script, and so on) from automatic upload.

Select Delete remote files when local are deleted to have IntelliJ IDEA automatically delete remote files during automatic uploads in case the local ones are deleted.

Note that this option serves as an extra safety measure and may result in unwanted files remaining on the remote server. As an example, consider a local file Foo.php , which is renamed to Bar.php . Since renaming a file is technically indistinguishable from deleting the file and creating a new one, the following will happen after automatic upload:

If the option is enabled, the remote server will only contain Bar.php .

If the option is disabled, the remote server will contain both Foo.php and Bar.php after automatic upload. You will probably need to delete Foo.php manually afterwards.

Enabling the Upload changed files automatically to the default server option also enables Upload to default server in Settings/Preferences | Tools | Actions on Save .

Download a file or folder

In the Remote Host tool window, select the required file or folder and choose Download from here from the context menu of the selection.

Download a file from the default deployment server

From the main menu, choose Tools | Deployment | Download from <default server> .

Как сохранить/экспортировать все настройки IntelliJ IDEA?

Я хотел бы переустановить свою операционную систему и сохранить IntelliJ IDEA настройки (например, цвета, отступы, проверки и т. д.). Есть ли способ сохранить мои настройки, чтобы сохранить их при переустановке операционной системы?

Вы можете сделать резервную копию папки конфигурации/плагинов так как экспорт настроек не повлияет на плагины. — CrazyCoder

@CrazyCoder Итак, чтобы подвести итог, для полного резервного копирования IDEA необходимо вручную создать резервную копию файлов в

/.IntellijIdea14 , экспортировать настройки по @Vic ниже, вручную создавать резервные копии конфигураций запуска по @Matt ниже и вручную создавать резервные копии нескольких других файлов в проекте. .idea файл и, возможно, некоторые .iml файлы? — jordanpg

@jordanpg Вы когда-нибудь находили ответ на свой вопрос выше? Это, конечно, кажется грязным, чтобы сделать это таким образом. — stepanian

@степанян нет. эта проблема с резервным копированием, вероятно, самая большая жалоба, которую я имею к IDEA. Я живу в страхе перед крахом Windows, пока IDEA находится в процессе переиндексации. — jordanpg

@jordanpg ха-ха! я тоже. — stepanian

7 ответы

Конечно : Файл → Настройки экспорта .

2020.01 версия

Сейчас это устарело. Вам нужно перейти в «Файл» -> «Управление настройками IDE» -> «Экспортировать настройки». Вы можете отключить «Репозиторий настроек» в разделе «Файл» -> «Настройки» -> «Плагины», но это, похоже, не имеет никакого значения для вашей способности экспортировать настройки «вручную».

В более поздних версиях кажется, что вам следует либо настроить репозиторий настроек, либо использовать плагин IDE Settings Sync. Дополнительная информация здесь:

IntelliJ IDEA позволяет вам обмениваться настройками между различными экземплярами вашей IDE. Это поможет вам воссоздать удобную рабочую среду, если вы работаете с разных компьютеров, и избавит вас от раздражающих вещей, которые выглядят или ведут себя не так, как вы привыкли.

Вы можете поделиться своими настройками одним из следующих способов:

Путем настройки репозитория настроек. Это позволяет вам синхронизировать любые настраиваемые компоненты (кроме списка включенных и отключенных плагинов), но требует настройки репозитория Git с настройками, которыми вы хотите поделиться. Эта опция полезна, если вы хотите реализовать одинаковые настройки среди членов вашей команды.

С помощью подключаемого модуля IDE Settings Sync. Он использует сервер JetBrains, поэтому дополнительная настройка не требуется. Синхронизированные настройки связаны с вашей учетной записью JetBrains, поэтому они не будут доступны другим пользователям. Настройки, которые вы можете синхронизировать, включают: темы IDE, раскладки клавиш, цветовые схемы, системные настройки, настройки пользовательского интерфейса, настройки меню и панелей инструментов, настройки представления проекта, настройки редактора, настройки завершения кода, подсказки имен параметров, живые шаблоны, стили кода и список. включенных и отключенных плагинов.

Почему в IntelliJ IDEA отсутствует опция "Сохранить как"?

Почему в IntelliJ IDEA нет простой опции save-as? Есть ли способ легко сохранить файл?

Вы можете попробовать Refactor → Copy. Это создает новый.java файл и переименует имя класса для вас, если файл является исходным кодом Java, иначе просто дублируйте текущий файл под новым именем.

Сохранить как по существу то же самое, что сделать копию файла под другим именем. Операция копирования IntelliJ IDEA предоставляется через рефакторинг, поэтому вы можете использовать Refactor | Скопируйте ( F5 ) вместо Сохранить как.

Как выгрузить созданную программу из Intellij Idea?

Нажмите ПКМ внутри main метода и затем run. Если точнее «run <имя класса*>.main()»
* Имя класса, в котором находится метод main.

Но если вы хотите не просто запустить, а собрать Runnable Jar файл из всего проекта, то так:
File -> Project Strucure -> Artifacts -> «+» (слева наверху, чуть правее угла) -> JAR -> From modules with dependencies. -> Выбираете Class с main методом -> Ok.

Всё, вы всё настроили, теперь, чтобы создать jar файл, надо нажать:
Build -> Build Artifacts -> выбрать Build в открывшемся списке.

Related Posts