I tried the following command in notebook. It creates a .cdf file.
CDFDeploy["C:\\Users\\Admin\\Desktop\\myfile.cdf",
Manipulate[Plot[x^a, {x, 1, 100}], {a, 1, 10}]]
But when I tried the same in external java program, its giving $Failed.
import com.wolfram.jlink.KernelLink;
import com.wolfram.jlink.MathLinkException;
import com.wolfram.jlink.MathLinkFactory;
public class testrun {
public static void main(String[] args) {
KernelLink ml = null;
try {
ml = MathLinkFactory.createKernelLink("-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/10.2/MathKernel.exe'");
} catch (MathLinkException e) {
System.out.println("Fatal error opening link: " + e.getMessage());
return;
}
try {
// Get rid of the initial InputNamePacket the kernel will send
// when it is launched.
ml.discardAnswer();
System.out.println(ml.evaluateToOutputForm("CDFDeploy[\"C:\\Users\\Admin\\Desktop\\myfile.cdf\",Manipulate[Plot[x^a,{x,1,100}],{a,1,10}]]",0));
} catch (MathLinkException e) {
System.out.println("MathLinkException occurred: " + e.getMessage());
} finally {
ml.close();
}
}
}