How can I fix “Compilation unit name must end with .java, or one of the registered Java-like extensi...

How can I fix “Compilation unit name must end with .java, or one of the registered Java-like extensions”?

            
         up vote 7down votefavorite
1

This error comes up in an alert box when I try saving my js file in eclipse:

Compilation unit name must end with .java, or one of the registered  Java-like extensions

In the breakpoints view I see this:

/module-foo/src/main/resources/frontend/foo/foo_base.js [entry] - ___anonymous()    
share |improve this question
 
  

3 Answers                                 3

         up vote 22down voteaccepted

I had an errant breakpoint set in the file. Removing the breakpoint resolved the problem.

The answer comes from a comment in another post, but was a bit obscure in the comments of a lower ranked answer here: JavaScript editor within Eclipse

Hopefully putting it here will make it easier to find as I didn't find much when I was trying to resolve this before.

share |improve this answer
 
                                                                                                                   
I doubt a breakpoint would lead to this error. Are you sure it's not a coincidence ? Any detail ?                     – Denys Séguret                 Aug 14 '14 at 19:02                                                                                                 
                                                                                                                   
I added a breakpoint to the js file, but it did not recreate the issue. I left it for a couple days and still nothing happened. So, I'm not sure what triggers the issue. I highly doubt I had put a breakpoint in there originally. It seemed that eclipse just got in an bad state. Restarting eclipse didn't help, only removing this odd breakpoint at the start of the file.                     – Noremac                 Aug 18 '14 at 13:51                                                                            
                                                                                                                   
Of course, after posting the above, I started getting the error again and apparently on the breakpoint I set a few days ago (except now the breakpoint is at the top of the file, just like the other one was). Is there anything you'd like me to try while I am getting the issue?                     – Noremac                 Aug 18 '14 at 20:37                                                                                                 
                                                                                                                   
There are so many cases of one of the many Eclipse caches getting corrupted that it's probably impossible to determine which Eclipse bug you encountered. In my opinion you should probably delete this QA as hopeless.                     – Denys Séguret                 Aug 19 '14 at 6:41                                                                            
                                                                                                                   
It's meant for as an answer, how to fix this issue. I wasn't expecting a full explanation, or as a bug report. This fixed it for me, and I only found it through an obscure comment. Putting it as QA makes the fix much more readily available.                     – Noremac                 Aug 19 '14 at 14:16                                                                            
            
         up vote 3down vote

I also fixed this by removing breakpoints. The interesting thing was, I wasn't able to remove the breakpoint by double clicking on it as you normally would.

I had to go into the Breakpoint View and right click and remove the breakpoint from this file. Directly afterwards, I tried to save again, and it was the first time the task completed.

share |improve this answer
 
  
         up vote 0down vote

I had an breakpoint set in the file.By Removing the breakpoint resolved the problem.

share |improve this answer
 
  
                                                         

 

draft saved
draft discarded
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误说明你的项目中有Java编译错误,这会导致自定义视图的渲染失败。你需要先解决编译问题。 你可以在Android Studio的底部的“Build”选项卡中查看详细的编译错误信息,并尝试修复这些错误。通常,这些错误可能是语法错误、缺少依赖项或命名冲突等问题导致的。 一旦你解决了编译错误,重新构建你的项目,你就应该可以正常使用自定义视图了。 ### 回答2: 这个项目中包含了Java编译错误,这可能会导致自定义视图的渲染失败。首先需要修复编译问题。 在Java编程中,编译错误是指在编译代码时出现的语法错误或逻辑错误。这些错误会导致编译器无法正确地将代码转换成可执行的计算机指令,从而导致程序无法正常运行或出现错误。 对于这个项目来说,由于Java编译错误的存在,可能会导致自定义视图无法正确地渲染。自定义视图是在项目中根据特定需求编写的自定义界面元素,它们依赖于正确的编译代码来实现预期的渲染效果。 为了解决这个问题,首先需要找到并修复代码中的编译错误。这可以通过检查编译器给出的错误消息或警告来定位问题的所在。常见的编译错误包括拼写错误、缺少分号、未声明的变量等。修复这些错误可能需要修改代码逻辑、调整语法或添加缺失的部分。 修复编译错误后,重新编译项目。重新编译会将修复后的代码转换成可执行的指令,从而使自定义视图能够正常渲染。 总之,要修复这个项目中的Java编译错误,以解决自定义视图渲染失败的问题,我们需要找到并修复代码中的编译错误,并重新编译项目。这将确保项目能够顺利执行,并正确渲染自定义视图。 ### 回答3: 这个项目包含Java编译错误,可能会导致自定义视图的渲染失败。首先修复编译问题。 当我们在编写Java代码时,编译器会检查代码中是否存在错误。如果代码中存在错误,编译器将无法将代码转换成可执行的机器代码,从而导致项目的编译错误。 在这个具体的项目中,Java代码中存在编译错误,这可能是由于语法错误、缺少引用或错误的数据类型等问题引起的。由于编译错误,项目的自定义视图无法正确渲染。 因此,我们需要首先解决这些编译问题。为此,我们可以逐行检查代码并查找错误。一旦找到错误,我们需要根据错误的类型采取相应的解决方案。例如,如果是语法错误,我们需要修正语法错误。如果是缺少引用,我们需要添加正确的引用。如果是错误的数据类型,我们需要更正数据类型。 一旦所有编译错误都得到修复,我们可以重新编译项目并确保没有任何编译错误。这样,我们就能够解决项目的编译问题,并确保自定义视图能够正确地进行渲染。 总之,修复Java代码中的编译错误是解决该项目的关键。一旦编译错误得到解决,自定义视图的渲染问题也将得到解决。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值