Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
what do you actually see? can you post a screen grab? –  Mike Honeychurch Jul 25 '12 at 9:31
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. –  Szabolcs Jul 25 '12 at 10:44
@MikeHoneychurch: i have edited my question. –  subbu Jul 25 '12 at 11:26
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... –  Albert Retey Mar 11 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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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