I have made a package

 t[x_]:=MessageDialog["This is top"]
 t1[x_]:=MessageDialog["This is top1"]

and used the code of this link and I am able to auto load packages in Mathematica and it is working fine. But when I have used it with Player Pro. It is not working.

Automatically load packages at startup

 initFileName = FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}];

(* Make a back-up *)
 CopyFile[initFileName, initFileName <> "_" <>
StringReplace[ToString@Round[DateList[]], " " -> ""] <> ".bak"];
exprs = Import[initFileName, {"Package", "HeldExpressions"}];

   Append[exprs, HoldComplete[Needs["VectorAnalysis`"]]],
     {"Package", "HeldExpressions"}

  Row[{Button["Click for function t", top`t[5]], Button["Click for f1", top`t[7]]}]

I have deployed the notebook in to CDF Player. But when I am opening the CDF by closing Mathematica and opening it with CDF Player, it is not working. I have also added that package in Autoload folder of Mathematica Player. What should I do so that my CDF or Player Pro also works fine as Mathematica notebook was working fine by autoloading packages at startup?

I was getting this output in mathematica when I clicked at "click for function t".enter image description here

But I am not getting any output when I click on these two buttons in case of CDF or Player Pro.

  • $\begingroup$ what do you actually see? can you post a screen grab? $\endgroup$ Commented Jul 25, 2012 at 9:31
  • $\begingroup$ I don't know anything about Player Pro, but I doubt that the CDF Player is customizable like this. CDFs are supposed to be portable and work everywhere, not only in a customized environment. $\endgroup$
    – Szabolcs
    Commented Jul 25, 2012 at 10:44
  • $\begingroup$ @MikeHoneychurch: i have edited my question. $\endgroup$
    – subbu
    Commented Jul 25, 2012 at 11:26
  • $\begingroup$ Have you seen this answer? I tried to summerize everything you'd need to load packages in Player Pro there, I don't think that things have considerably changed since then. The free CDF Player can not load packages, except if the CDF Player was specially signed, e.g. with an Enterprize License for Mathematica... $\endgroup$ Commented Mar 11, 2015 at 12:05

1 Answer 1


The main problem is that init.m file is different for Mathematica and Players:

expr = Dynamic[Column[{
      FileNameDrop[#, 3],
      Import[#, "Text"]
      }] &@FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}]];

CDFDeploy[ FileNameJoin[{$TemporaryDirectory, "userbasedirectory.cdf"}], expr, 
            Method -> "Standalone"]
SystemOpen @ %

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.