generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 36
Java formatting preferences
Achal Talati edited this page Nov 13, 2024
·
2 revisions
Follow the steps given below to setup the custom formatter preferences:
- Install NetBeans.
- Configure your Java formatting preferences in NetBeans:
Menu: Tools | Options | Editor | Formatting
In the "Language" drop-down: Choose "Java" - Press "Export" button (lower left corner)
- Check the "Editor" and "Formatting" checkboxes.
![image](https://private-user-images.githubusercontent.com/55803675/286356130-38037fa6-2f11-403a-8ce9-11d1fd0044a7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTE5MTUsIm5iZiI6MTczOTAxMTYxNSwicGF0aCI6Ii81NTgwMzY3NS8yODYzNTYxMzAtMzgwMzdmYTYtMmYxMS00MDNhLThjZTktMTFkMWZkMDA0NGE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDEwNDY1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUxNDY0MmUwMmNjNjFiYWU2NmFlZmVhMzdhN2UzN2MzNmZjYzJlMjEzMTc0MTE4MjQzNDk0ZDkxZWI3MDMyZDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.1fl6cS07KSsZkdOg_KEeuv6qH06et4AWvEU6v_uLEA8)
- Export the options as a .zip file, e.g. "MyNetBeansJavaFormatting.zip"
- Set the
jdk.format.settingsPath
setting in VS Code:
In VS Code, open the "Command Palette" (Ctrl+Shift+P)
Type "Preferences: Open User Settings (JSON)"
Set the following property:
"jdk.format.settingsPath": "PATH_TO_EXPORTED_NETBEANS_FORMAT_PREFERENCES_ZIP"
- You might also need to make sure that "Editor: Default Formatter" is set to "null" in your VS Code Settings (Ctrl+,).
Your custom Java formatting preferences should now be honoured by the "Oracle Java" extension in VS Code.
While it may not be the perfect solution, performing this task should be a one-time requirement, unless you find yourself regularly adjusting your formatter settings.