Why do I receive the error "Undefined function or variable 'usejava'" when trying to start MATLAB 6.x (R12.x)?
21 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2009 年 6 月 27 日
回答済み: Neil Guertin
2017 年 11 月 17 日
I receive the following error when I attempt to start MATLAB:
??? Undefined function or variable 'usejava'.
Error in ==> /usr/local/matlabr12/toolbox/local/matlabrc.m
On line 58 ==> if usejava('Desktop')
MATLAB is also not recognizing any basic commands, such as "helpdesk":
helpdesk
The above command results in the following error:
??? Undefined function or variable 'helpdesk'.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
This problem usually occurs when your pathdef.m file has become corrupted. The pathdef.m file defines the MATLAB Search Path. If this file has become corrupted, MATLAB will not be able to find any commands to execute.
For information on how to regenerate your pathdef.m file, see the solutions attached at the bottom of this page.
Alternatively, to manually fix the problem, follow these steps:
1. Open the pathdef.m file in any text editor. This file can be found in:
$MATLAB/toolbox/local (where $MATLAB is the root MATLAB directory)
The file will look something like this, depending on which products you have installed and which platform you are on:
function p = pathdef
%PATHDEF Search path defaults.
% PATHDEF returns a string that can be used as input to MATLABPATH
% in order to set the path.
% Copyright 1984-2000 MathWorks, Inc.
% $Revision: 1.4 $ $Date: 2000/06/01 16:19:21 $
% PATH DEFINED HERE -- Don't change this line.
p = [...
matlabroot,'/toolbox/compiler:',...
matlabroot,'/toolbox/images:',...
matlabroot,'/toolbox/local:',...
etc...
2. If you are running under UNIX/Linux, go to the $MATLAB/toolbox directory and obtain a directory listing by typing "ls" at the UNIX prompt. If you are running under Windows, you can just view the contents of this directory with the Windows Explorer.
3. Use the information from Step 2 to correct your pathdef.m file. You should have a listing for each directory within your $MATLAB/toolbox directory. Also, if any of these directories have subdirectories, you will have to add them too. Do not add subdirectories that are titled "private", "ja", or start with a @ symbol. For example, if you have the Control System Toolbox installed, you should have the following listings in your pathdef.m file:
matlabroot,'\toolbox\control\control;',...
matlabroot,'\toolbox\control\ctrlguis;',...
matlabroot,'\toolbox\control\ctrlobsolete;',...
matlabroot,'\toolbox\control\ctrlutil;',...
matlabroot,'\toolbox\control\ctrldemos;',...
This example is from a PC-Windows pathdef.m file. The previous example from Step 1 is from a UNIX/Linux pathdef.m file.
4. When you have added all of the necessary directories to the pathdef.m file, save the file and restart MATLAB. If you are storing files in the $MATLAB/work directory, make sure it is listed in the pathdef.m file as well.
0 件のコメント
その他の回答 (1 件)
Neil Guertin
2017 年 11 月 17 日
Instead of rewriting pathdef.m manually, the safest and best way to regenerate it is as follows:
- Delete pathdef.m
- Recreate pathdef.m as an empty file
- Open MATLAB again (You will get some errors)
- Run the following commands:
restoredefaultpath
rehash toolboxcache
savepath
This will find all MathWorks toolboxes installed. Any third party toolboxes will have to be added again with "addpath" and "savepath".
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!