Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » code style (and auto formatting) not working
code style (and auto formatting) not working [message #1858404] Sat, 01 April 2023 00:51 Go to next message
Roman Chyla is currently offline Roman ChylaFriend
Messages: 6
Registered: February 2016
Junior Member
Hello, I cannot get even the simplest code style to work.

A simple test: Java > Code Style > Edit default eclipse style > Set indentation to 8 > save under different name > edit java and apply (ctrl+shift+f)

or with:

Set Java > Editor > Actions > Format all code on save

if I insert multiple spaces between tokens, they get collapsed -- so some code cleanup clearly happens, but not the "code formatting"

I tried Eclipse 20230-3, 2022-?? -- updated everything; played with profiles. This is on Ubuntu with Amazon corretto, made a fresh install - but used the same workspace...

I can't find any errors in the error.log; eclipse verbose output is no revealing anything (to me at least), been at it for the past few hours and am really stuck. Would appreciate a nudge in the right direction.

[Updated on: Sat, 01 April 2023 00:52]

Report message to a moderator

Re: code style (and auto formatting) not working [message #1858405 is a reply to message #1858404] Sat, 01 April 2023 05:27 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 147
Registered: October 2018
Senior Member
Hello,

Works OK in my case.

Regards.

[Updated on: Sat, 01 April 2023 13:50]

Report message to a moderator

Re: code style (and auto formatting) not working [message #1858418 is a reply to message #1858405] Sun, 02 April 2023 00:38 Go to previous messageGo to next message
David M. Karr is currently offline David M. KarrFriend
Messages: 813
Registered: July 2009
Senior Member
Are you certain that Eclipse knows you're working on a Java source file?
Re: code style (and auto formatting) not working [message #1858427 is a reply to message #1858418] Sun, 02 April 2023 17:52 Go to previous message
Roman Chyla is currently offline Roman ChylaFriend
Messages: 6
Registered: February 2016
Junior Member
Unfortunately, I got trapped by this: https://github.com/google/styleguide/issues/687 -- eclipse formatter + google style produce vastly different results from `google-java-format` plugin. E.g. method parameters are not on separate lines.

On top of that, the plugin was not working (activated) in the recent Eclipse -- no errors; I figured that out only after trying with an older eclipse - which produced the error.

this needs to be passed (eclipse.ini)

```
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
```

so three problems conspired to make my life miserable
Previous Topic:Exam Seating Arrangement System in Java
Next Topic:how to install "import java." and "import javax.
Goto Forum:
  


Current Time: Fri Sep 20 20:11:12 GMT 2024

Powered by FUDForum. Page generated in 0.02266 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top