How to run blender from a different java based application?

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
Sikha Devi
Posts: 0
Joined: Mon Sep 04, 2006 2:08 pm
Location: India

How to run blender from a different java based application?

Post by Sikha Devi » Tue Sep 12, 2006 10:39 am

I want to run blender from a different java based application . I have created blender menu in the menubar of that application. When i click the 'run' menuitem in the blender menu the default scene of blender should come so that the i can start working in blender.I have placed blender-2.42a-linux-glibc232-py24-i386-static directory which is used to run blender in my system, in a directory 'tools' which is under the directory where all the files of that application resides . I have used this coding
public static void runblender () {
String appinterfaceExePath = Utils.USER_DIR + Utils.FILE_SEPARATOR +"tools"+ Utils.FILE_SEPARATOR +"blender-2.42a-linux-glibc232-py24-i386-static" + . + Utils.FILE_SEPARATOR + "blender";
Runtime r = Runtime.getRuntime():
r.exec(appinterfaceExePath):
} But blender does not run in this way.
Will u plz provide me the actual java coding for it ?
Thanking you.
Sikha Devi.
S.Devi

tsodzil
Posts: 0
Joined: Thu Aug 10, 2006 5:17 am

Post by tsodzil » Wed Sep 13, 2006 3:12 am

Have you dried to debug the path to the blender-binary?

Also surround the runtime call with a try+catch. so that a exception is thrown if something does not work.

simonharvey
Posts: 0
Joined: Tue May 18, 2004 8:11 am

Post by simonharvey » Wed Sep 13, 2006 11:43 am

tsodzil wrote:Have you dried to debug the path to the blender-binary?
Sorry, but I thought that was quite funny. I usually debug my code the second ive gotten out of the shower.

Kind Regards
Simon Harvey


Edit: :D.

Sikha Devi
Posts: 0
Joined: Mon Sep 04, 2006 2:08 pm
Location: India

Post by Sikha Devi » Wed Sep 13, 2006 2:01 pm

Sorry! I couldnot understand the meaning of your reply. Will you plz explain how can i debug the path to the blender binary? I am working in linux 2.6.12-12mdk.
Thanking you.
Sikha Devi
S.Devi

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv » Wed Sep 13, 2006 3:05 pm

It has been a while since I was a victim of Java, but my random guessing is there is something missing from the runtime setup like a home directory or an environment variable like $HOME.

Running blender with the -d flag and capturing the output might give clues.

Sikha Devi
Posts: 0
Joined: Mon Sep 04, 2006 2:08 pm
Location: India

How to run blender from a java application ?

Post by Sikha Devi » Fri Sep 15, 2006 3:06 pm

I runned blender in this way
./blender -d and got these informations args[0]=./blender
args[1]= -d
I have coded in this way to run blender from the menubar of a diffrent java based application

public static void runblender{
String cmd="./blender";
String cmds[] = {"/home/sda_tr3/incad_new/tools/blender-2.42a-l
inux-glibc232-py24-i386-static","./blender" };
String envp[]=null;
String dir= Utils.USER_DIR + Utils.FILE_SEPARATOR +"tools"+ U
tils.FILE_SEPARATOR +"blender-2.42a-linux-glibc232-py24-i386-static" ;
File file=new File(dir ) ;
try
{
Runtime r= Runtime.getRuntime();
Process process = r.exec(cmd,null,file);
}
catch(IOException e) {
e.printStackTrace();
}
}

But it is showing io exception . Am i wrong in using the actual form of exec method ?Should i set environment variables to the values where the menubarclient.xml, the xml file where the menubar items of the java application are set or to the blender -2.42a-linux-glibc232-py24-i386-static directory ? Plz guide me.
Thanking you
Sikha Devi
S.Devi

Post Reply