Click here to Skip to main content
15,906,455 members
Home / Discussions / Java
   

Java

 
Questionfull answer with code pls Pin
Member 159126962-Feb-23 12:06
Member 159126962-Feb-23 12:06 
AnswerRe: full answer with code pls Pin
jschell6-Feb-23 6:21
jschell6-Feb-23 6:21 
AnswerRe: full answer with code pls Pin
Dave Kreskowiak6-Feb-23 6:32
mveDave Kreskowiak6-Feb-23 6:32 
GeneralRe: full answer with code pls Pin
Andre Oosthuizen8-Feb-23 4:30
mveAndre Oosthuizen8-Feb-23 4:30 
AnswerRe: full answer with code pls Pin
Richard MacCutchan6-Feb-23 6:37
mveRichard MacCutchan6-Feb-23 6:37 
AnswerRe: full answer with code pls Pin
Gerry Schmitz6-Feb-23 6:39
mveGerry Schmitz6-Feb-23 6:39 
QuestionUsing JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 20:38
JohnCodding25-Jan-23 20:38 
AnswerRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan25-Jan-23 22:31
mveRichard MacCutchan25-Jan-23 22:31 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 22:47
JohnCodding25-Jan-23 22:47 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:02
mveRichard MacCutchan26-Jan-23 0:02 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:16
JohnCodding26-Jan-23 0:16 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 23:27
JohnCodding25-Jan-23 23:27 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:05
mveRichard MacCutchan26-Jan-23 0:05 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:20
JohnCodding26-Jan-23 0:20 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:28
mveRichard MacCutchan26-Jan-23 0:28 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:45
JohnCodding26-Jan-23 0:45 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:52
JohnCodding26-Jan-23 0:52 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 1:44
mveRichard MacCutchan26-Jan-23 1:44 
AnswerRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
jschell26-Jan-23 11:33
jschell26-Jan-23 11:33 
QuestionMemory usage for requested rows from database Pin
Valentinor13-Jan-23 0:18
Valentinor13-Jan-23 0:18 
AnswerRe: Memory usage for requested rows from database Pin
jschell15-Jan-23 8:27
jschell15-Jan-23 8:27 
GeneralRe: Memory usage for requested rows from database Pin
Valentinor16-Jan-23 20:44
Valentinor16-Jan-23 20:44 
GeneralRe: Memory usage for requested rows from database Pin
jschell17-Jan-23 3:24
jschell17-Jan-23 3:24 
AnswerRe: Memory usage for requested rows from database Pin
RedDk17-Jan-23 7:15
RedDk17-Jan-23 7:15 
QuestionHow to found a file by utilizing a variable for 'Startswith' in JAVA? Pin
MOHAMMAD ZAINUL ABIDEEN3-Jan-23 0:32
MOHAMMAD ZAINUL ABIDEEN3-Jan-23 0:32 
I'm trying to find a file based on the starting eight digits extracted from an excel sheet for every iteration. I am receiving the error notice "Local variable CaseID declared in an enclosing scope must be final or effectively final" so i am using the code below and still appears to be fresh, so I don't know how to correct this, Even after it happen to be a straightforward repair.

Java
package Chrome;
//CHROME
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;


public class ValidateInput {

public static void main(String[] args) throws Throwable {
// TODO Auto-generated method stub

// String filePath=System.getProperty("user.dir")+"\\UP.xlsx";
//File src = new File(filePath);    
//System.out.println(filePath);
File src = new File("C:\\Users\\Z246379\\Documents\\TestDataFolder\\ValidateInput.xlsx");          
FileInputStream fis = new FileInputStream(src);        



XSSFWorkbook wb = new XSSFWorkbook(fis);        
XSSFSheet Sheet1 = wb.getSheetAt(0);
int i1 = 2;
//Username
String data0 = Sheet1.getRow(2).getCell(0).getStringCellValue();
//Password    
String data01 = Sheet1.getRow(2).getCell(1).getStringCellValue();
//Case ID
String caseID = Sheet1.getRow(i1).getCell(2).getStringCellValue();
// Description
String Desc = Sheet1.getRow(2).getCell(3).getStringCellValue();
//Internal Claim File
String ICF = Sheet1.getRow(1).getCell(4).getStringCellValue();
String CRPT = Sheet1.getRow(1).getCell(5).getStringCellValue();

// final String caseID1 = caseID1;




//Chrome driver code

 System.out.println("Called openBrowser");
 String exePath = System.getProperty("user.dir")+"\\chromedriver.exe";
 System.setProperty("webdriver.chrome.driver", exePath);
 ChromeOptions options = new ChromeOptions();
 options.setExperimentalOption("useAutomationExtension", false);
 options.addArguments("start-maximized");
 options.addArguments("--no-sandbox");
 options.addArguments("--disable-extensions-except");
 options.addArguments("disable-extensions");
 //options.setExperimentalOption("useAutomationExtension", false); 
 WebDriver driver = new ChromeDriver(options);
 driver.get("https://client.abc.com");


 //Logging in       
 driver.findElement(By.xpath("//input[@id='userid']")).sendKeys(data0);
 driver.findElement(By.xpath("//body[@class='no-nav']/div[@id='wrapper']/header[@class='header']/div[@class='container']/div[@class='menu']/div[@class='drop']/div[@class='login-form']/form[@method='POST']/div[2]/input[1]")).sendKeys(data01);
 driver.findElement(By.xpath("//input[@value='Sign In']")).click();
 Thread.sleep(2000);
 //Navigate to Validate Input
 driver.findElement(By.xpath("//span[@class='wpsNavLevel2'][contains(text(),'EZ-Test')]")).click();
 Thread.sleep(3000);
 driver.get("https://ezt.abc.com/Test/inputFiles/selectValidateInput/selectValidateInput.xhtml");

 while (caseID != null)
      {

  caseID = Sheet1.getRow(i1).getCell(2).getStringCellValue();
  //Input Validate Input stuff

  driver.findElement(By.xpath("//input[@id='mainForm:caseId']")).sendKeys(caseID);
driver.findElement(By.xpath("//input[@id='mainForm:testBedDesc']")).sendKeys(Desc);
  driver.findElement(By.xpath("//select[@id='mainForm:customRptOptions']")).sendKeys(ICF);
 driver.findElement(By.xpath("//span[@id='mainForm:customReportLabel']")).click();




  File dir = new File("C:\\Users\\Z333379\\Documents\\Test beds");
  FilenameFilter filter = new FilenameFilter() {
  public boolean accept (File dir, String name) { 
   return name.startsWith(caseID); //this is where i get the error. its not letting me make case ID a variable. but i really need the starts with stuff
   } 
 }; 
 String[] children = dir.list(filter);
 if (children == null) {
    System.out.println("Either dir does not exist or is not a directory"); 
 } else { 
   for (int i=0; i< children.length; i++) {
   String filename = children[i];
   System.out.println(filename);
        driver.findElement(By.xpath("//input[@id='mainForm:comprehensive']")).sendKeys("C:\\Users\\Z246379\\Documents\\Test beds\\" + filename);
    } 
 } 

 driver.findElement(By.xpath("//button[@id='mainForm:reset']")).click();


 i1=i1+1;
      }

  }
}



This is from the source I read, I don't know how to define an inner local class with a mutable variable. Is that correct? This problem appears to be at the bottom of the code, at the caseID variable.

modified 3-Jan-23 7:15am.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.