run python file from java class by eclipse IDE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rspvsanjay
    New Member
    • Sep 2016
    • 21

    run python file from java class by eclipse IDE

    This program (below), I am able to run from command prompt but when i am using eclipse that is not returning any text.

    May this is not running python file

    java file and python file is present in bin folder when i am using command prompt

    when i am using eclipse java and python both file is present in default package .

    what i do to run python file from java class by eclipse IDE ?
    Code:
    public class TestE 
    {
    	static String returnText(String s7) 
    	{	StringBuilder result=null;	
    	try{
    			final String command = "python sir_desc.py "+s7;
    			final Process sirDesc = Runtime.getRuntime().exec(command);
    
    			final java.io.InputStream inStreamBase = sirDesc.getInputStream();
    
    			final java.io.InputStreamReader inStreamISR = new java.io.InputStreamReader(inStreamBase);
    
    			final java.io.BufferedReader inStream = new java.io.BufferedReader(inStreamISR);
    
    			String inLine;
    
    			result = new StringBuilder();
    
    			while (null != (inLine = inStream.readLine()))
    
    			result.append(inLine);
    					
    			}
    			catch(Exception e){}
    		return result.toString();
    	}
        
    
     public static void main(String args[])
     {
    	 System.out.println("start  :  "+returnText("https://en.wikipedia.org/wiki/Varanasi"));
     }
    }
    Attached Files
    Last edited by Frinavale; Nov 18 '16, 04:10 PM.
Working...