'binary.startprofile is not working. startprofile is not present in selenium-jar file.I even tried old versions still not working

I am writing code in java with selenium- In my code binary.startprofile is not working. it is saying startprofile is not present in selenium-jar file. I even tried old versions still not working. I am using java with Eclipse. I've tried everything but still not working for me.

package botjava;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.FirefoxDriver;


public class web {


public static void main(String[] args) throws InterruptedException {
       System.setProperty("webdriver.gecko.driver", "C:\\Users\\user\\\\Desktop\\g\\geckodriver.exe"); 
       File torProfileDir = new File( "C:\\Users\\user\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default"); 
       FirefoxBinary binary = new FirefoxBinary(new File("C:\\Users\\user\\Desktop\\Tor Browser\\Browser\\firefox.exe")); 
       FirefoxProfile torProfile = new FirefoxProfile(torProfileDir); 
       torProfile.setPreference("webdriver.load.strategy", "unstable"); 
      
       try 
       { 
        binary.startProfile(torProfile, torProfileDir,""); 
        
       } 
       catch (IOException e)
       { 
        e.printStackTrace(); 
       } 
       FirefoxProfile profile = new FirefoxProfile(); 
       profile.setPreference("network.proxy.type", 1); 
       profile.setPreference("network.proxy.socks", "127.0.0.1"); 
       profile.setPreference("network.proxy.socks_port", 9150); 
       FirefoxDriver driver= new FirefoxDriver(); 
       Thread.sleep(10000); 
       driver.get("https://www.facebook.com/"); 
       Thread.sleep(5000); 
       killFirefox();
       System.out.println("URL has been loaded successfully");
       } 
       private static void killFirefox() 
       { 
        Runtime rt = Runtime.getRuntime(); 
        try 
        { 
         rt.exec("taskkill /F /IM firefox.exe"); 
         while (processIsRunning("firefox.exe")) 
         { 
          Thread.sleep(100); 
         } 
         } 
        catch (Exception e) 
        { 
         e.printStackTrace(); 
         } 
       } 
       private static boolean processIsRunning(String process) 
       { 
        boolean processIsRunning = false; 
        String line; 
        try 
        { 
         Process proc = Runtime.getRuntime().exec("wmic.exe"); 
         BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream())); 
         OutputStreamWriter oStream = new OutputStreamWriter(proc.getOutputStream()); 
         oStream.write("process where name='" + process + "'"); 
         oStream.flush(); 
         oStream.close(); 
         while ((line = input.readLine()) != null) 
         { 
          if (line.toLowerCase().contains("caption")) 
          { 
           processIsRunning = true; 
           break; 
           } 
          } 
         input.close(); 
         } 
        catch (IOException e) 
        { 
         e.printStackTrace(); 
         } 
        return processIsRunning;  
       }

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source