cannot get streams work on eclipse - eclipse

I recently installed JDK 8 on my Eclipse (MAC) and I m trying to use the streams.
However, it seems that Java 8 is not correctly configured since I get the following error on the following line of code:
List<Eshop> tempShops = eshops.stream().filter( e -> e.getName().equals(name)).collect(Collectors.toList());
Multiple markers at this line
- e cannot be resolved to a variable
- e cannot be resolved
- Syntax error on token "-", --
expected
Anybody has an idea what might be wrong?
EDIT
Also tried like
List<Eshop> tempShops = eshops.stream().filter( (e) -> e.getName().equals(name)).collect(Collectors.toList());

Eclipse Kepler did not contain Java 8 support (unless you installed a patch).
You should use the current Eclipse Neon (4.6.1) for full Java 8 support.

I had the same problem. I created a predicate separately and the java.util.function.Predicate package got auto imported and the error was resolved.
You could try something like this:
Predicate shop = e -> {return e.getName().equals(name);};
List tempShops = eshops.stream().filter(shop).collect(Collectors.toList());

Related

Pydev debugger error - NameError: name 'psort' is not defined

I am getting an error message from Pydev in the Eclipse Console window when debugging Python code. The same error message repeats every time the debugger pauses:
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
Traceback (most recent call last):
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 63, in process_net_command
cmd = on_command(py_db, cmd_id, seq, text)
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 367, in _cmd_exec_or_evaluate_expression
trim_if_too_big = int(trim) == 1
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
This is not a bug in my own code, and I don't know how to fix it. I can't tell if is my configuration or a Pydev bug, or what? The debugger still works, but the console window gets filled up with those repeated messages.
I have been tolerating it for some months, thinking I just had to update Pydev, but I finally updated Pydev today(11/2021) and I still get the error messages.
I am using:
Windows 10 64bit
Eclipse IDE for C/C++, Version: 2020-12 (4.18.0), Build id: 20201210-1552
The Pydev version I updated to today:
Pydev version 9.2.0.20211031131
I may have solved this, or at least a very similar looking problem. I think it was caused by some references in the Eclipse 'Expressions' view. I had let many expressions accumulate in the Expressions View. Some referenced deleted variables, out of scope variables, or variables whose definitions had changed - so expressions using them may have been buggy.
I stopped the errors by removing all of the expressions in the 'Expressions' view. I was then able to add expressions again without causing the error.
Sorry to say, I didn't identify the problem expression(s), so I didn't get to find out how they caused the problem.

Eclipse gives too many false errors and warnings on EL expressions in JSF files

I have run into a weird situation. I have an application which was originally developed in RAD and uses a construct like
rendered="#{bean.show and user.can('foo')}"
Our developers use mix of RAD and Eclipse Juno / Kepler. So we need to make the code work in both the environments.
In RAD, the above line does not generate any errors. When I export the project as archive and import it into Eclipse Juno, it generates this error
Cannot apply expression operators to method bindings
Our environment is Websphere 8.5, RAD / Eclipse, JSF 2.1
How can I fix this?
In general, if you face a false EL validation error in a JSF file in Eclipse, try peeking around in Window > Preferences > Web > JavaServer Faces Tools > Validation and tune some settings currently (unnecessarily) set at Error.
Your particular problem is triggered by "Applying operator to method binding" which indeed defaults to Error. If upgrading Eclipse to most recent version is somehow not an option, setting it back to Warning should tone down it.
After all, EL validation in Eclipse is quite an epic fail. It seems like it's using regular expressions to validate EL syntax instead of a true stack based parser like as EL itself is doing. There are several entries below "Type Coercion Problems" and "Type Assignment Problems" which are unnecessarily set to Error and known to cause false errors.
See also:
Method must have signature "String method() ...[etc]..." but has signature "void method()"
Eclipse errors on #{component.valid}: "valid cannot be resolved as a member of component”
I had the same error with any of these statements:
<h:panelGroup rendered="#{!bean.isValid(obj)}">
<h:panelGroup rendered="#{not bean.isValid(obj)}">
I resolved the error by changing the statement as follows:
<h:panelGroup rendered="#{bean.isValid(obj) == false}">
I found yet another example that resolved the problem:
<ui:fragment rendered="#{bean.isValid(obj) eq 'false'}">

Static type checking error for groovy collection.addAll

This message is also posted on grails mailing list.
In addition to my earlier question I downloaded the grails source from github.
Building via documented gradlew install works (almost) perfect. Than I imported the whole project into Eclipse. And with a bit fighting groovy plugins and "project - workspace-groovy-compiler-issues" I only have a few issues left, all boiling down to java Collection modification in groovy classes. For instance in PluginBuildSettings.groovy:
List<Resource> artefactResourcesList = []
...
artefactResources.addAll compileScopePluginInfo.artefactResources
which gives an error:
Groovy:[Static type checking] - Cannot call java.util.List#addAll(java.util.Collection ) with arguments [java.util.Set ]
I really don't see what the issue may be.
I tried changing the artefactResources declaration in PluginScopeInfo from:
Set<Resource> artefactResources = []
to:
Set<Object> artefactResources = []
which takes away error above, but introduces some other problems let alone the unittests. I'm not hindered with extensive groovy knowledge but it looks all perfect valid to me.
I'm using ggts:
Groovy/Grails Tool Suite
Version: 3.1.0.RELEASE
Build Id: 201210061306
groovy-compiler: 2.0.4.xx -20120921
On mac os x 8.2
java 6.0._37
groovy compiler: 2.0 (workspace and project).
With my favorite search engine I found a reference to grails bug 5516, which is solved but it looks resurected
Type checker fails verification of generic types with addAll
Fixed in 2.0 rc 3,

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script7.groovy: 1: unable to resolve class

I am currently receiving this error when trying to run a soapui file:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed: Script7.groovy: 1: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate # line 1, column 1.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1206)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:585)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:832)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:495)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:472)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:141)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
1 error
soapUI code:
import com.company.ui.test.SoapUI_T11001_StockConsSecurityCurBusiDate
def env = testRunner.testCase.testSuite.project.getPropertyValue("env")
def baseUrl = testRunner.testCase.testSuite.project.getPropertyValue("baseUrl")
log.info("The baseurl is "+baseUrl)
log.info("The env under test is "+env)
SoapUI_T11001_StockConsSecurityCurBusiDate testStep = new SoapUI_T11001_StockConsSecurityCurBusiDate();
testStep.init(baseUrl);
testStep.execute(null);
eclipse code:
package com.company.ui.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.eviware.soapui.model.support.AbstractSubmitContext;
import com.eviware.soapui.model.testsuite.TestRunner;
public class SoapUI_T11001_StockConsSecurityCurBusiDate extends BaseSelenium{
public static void main(final String[] args){
final SoapUI_T11001_StockConsSecurityCurBusiDate ico = new SoapUI_T11001_StockConsSecurityCurBusiDate();
try{
ico.init("https://avncedevn1.nam.nsroot.net:17620/", false);
}catch(Exception e){
// TODO Auto-generated catch block
e.printStackTrace();
}
ico.execute(null);
}
//...code....
}
how do I solve this error ? I'm not sure what is causing the error.
This work for me:
Press Ctr+Alt+Shift+s
or:
From File menu -> Project Structure -> SDK Location -> JDK location Drop down menu choose:
Embeded JDK c:....\jre
Then ok.
If you using android studio and got this error then I solved it changing the Gradle version of the project to the newest version 6.2.1 on the project structure options.
One of the possible reasons is that the jdk version is too high. For example, using jdk 16 to build the source code of Apache Kafka throws this error. Using jdk 11 is fine.
bild.gradel file in change clashpath
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
}
gradel-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
I'm Using Android Studio - Arctic Fox and this worked for me
Go To File menu -> Project Structure -> SDK Location -> Gradle Setting
Then check the "Download external annotations for dependencies" button and select JDK location from the drop down menu and choose: Android Default Jdk Vesion.
Click on Ok.
If you wanted to make a new project on Android Studio after first install, probably you write your application name including (') sign as called apostrophe.
For Example, I tried to set a name as: "Henry's Game" but apostrophe caused Android Studio to not load because of this mistake:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
So, just change your application's name, and simply use Latin alphabet languages such as English.
To fix: Go to your Android Project Tree and find Gradle Scripts > settings.gradle > change the name:
rootProject.name='Henry Game'
include ':app'
With Eclipse Juno (Kepler Release) Build id: 20121114-2344, I found similar problem:
org.codehaus.groovy.control.multiplecompilationerrorsexception startup failed unable to resolve class Chart
The class Chart is my container class for some utilities for charting.
I tried outside of Eclipse, with Groovy 2.0 Console the same code segment works fine. After scratching my head for about 3 hours, I resolved it by adding the following
import excel.Chart
in the invoking class with main() that has "new Chart()" thus getting the complaints, once added, the error is gone. Even more weird, after passing the error, I remove that import, there is still no more complaints! (All my scripts/classes are under the same package excel, I suppose such import statement is not needed.)
One of the symptom of the complaints is that there was not Chart.class generated in the output bin folder. Once the complaints gone, Chart.class appeared there.
I guess that it might be a bug of Eclipse/Groovy plugin (I use Groovy Plugin for Juno).
Hope my understanding is correct, and it helps.
The solution for me was change the gradle version and the Gradle JDK:
File > Project Structure > Project
enter image description here
File > Project Structure > SDK Location
enter image description here
Go to Files and click Invalidate caches/ Restart . Android studio will clear the cached and it will be restarted without any error.
Hope this answer helps you :)
For this problem, you might also encounter package naming from gsp as I did. In the build/gsptmp folder, Grails 4.x.x creates temporary gsp files to link the classes that they refer to. Due to the change of a package name it was failing to do so in my case. Try with command grails war --stacktrace during war build!
Previously, it was <%# page import="bv.BankReconciliationController" %>
but the folder bv was renamed to factoring.
So, the solve was to change the import to
<%# page import="factoring.BankReconciliationController" %> and it worked :)
I have also faced the same and tried all of the solution here and other places as well, at last i deleted my .gradle and gradle both folder and caches of android studio and open the studio again and rebuild the project, it's works after that fine and used the latest gradle version and previously it was picking up the older version and causing issues.
for me , solution is to upgrade the gradle to latest version , and remove the .idea file , and invalidate caches and restart android studio.
When starting a project make sure to select SDK version 11 or later. It will default to a minimum SDK but you have to scroll down to a later version for it to work. Then the project should load and build.
For me, I just delete the .grade file under program files(C:\Users\username\ .gradle) in windows and it will work.
This work for me:
From File menu -> Project Structure -> SDK Location -> klik Gradle Setting for show hide menu, Gradle JDK choose:
Embeded JDK c:....\jre
Then ok.
Do you have the grail and groovy plugin installed? If so try uninstalling this plugin. I had the same error message and uninstalling the plugin, restart IDE worked for me.

read.csv(file.choose()) problem in StatET/Eclipse

When trying to read a csv file in StatET/Eclipse (OS X 10.6, Eclipse 3.6) using the following command:
read.csv(file.choose(),header=T)
I get the response:
Error in file.choose() : file choice cancelled
The command works as expected in 'R' itself and reading a named csv file works in StatET. What am I doing wrong?
Thanks in advance.
Update: submitting this question to statet-user#lists.r-forge.r-project.org secured a response from Stephan Wahlbrink
Updating StatET to 0.9.2 should fix
the problem.
Updating from within Eclipse (Help > Check for Updates) to the latest version (site-statet-00.09.02 [ 2011-01-03 | stable | Eclipse 3.6 ]) did indeed fix the problem.
Many thanks to Stephan.
Everything seems ok for me. My platform is StatET/Eclipse(win7-x64, Eclipse 3.6).
Only when I click 'cancel' in the select file dialog, it will give that error message.