Bookmark Topic Watch Topic
  • New Topic

Calling python function from java . NEED HELP URGENT

 
Geetu Kumari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi

I want to call python function from java Class OR execute python file from java Class
if possible Please explain me with piece of code urgently .......

Thanks in advance,
Geeta

I tried for this ... but it not giving any error and not executing also .....

public class MyJavaClass
{
public static void main(String[] args)
{
try
{
System.out.println("start");
String file = "/home/geeta/Install/newEclipse/NoCrashPlease/testWebProject/src/pythonPrograms/test.py" ;
Process p =Runtime.getRuntime().exec("chmod -R 777 " + file);
p.waitFor();
p = Runtime.getRuntime().exec("python " +file);
p.waitFor();
System.out.println("end........................");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

/* test.py contain */
print 'SUCCESS'
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.
 
    Bookmark Topic Watch Topic
  • New Topic