How to properly import jar file for standalone application

13 views (last 30 days)
I am using a websocket library containing .m files that reference a .jar package. The application will be deployed with the Application compiler, but i have a very hard time figuring it out, despite looking into all functions related to modifying the classpath. (i am about to loose it)
The project structure in folder 'main' is simple
./main.m
./HandleServer.m
./3party/Server.m (abstract handle class)
./3party/ws.jar
The code in main instantiates the HandleServer < Server, but first problem (nothing to do with jar):
The specified superclass
'Server' contains a parse
error, cannot be found on MATLAB's
search path, or is shadowed by
another file with the same name.
and but it is on the dynamic classpath in main.m:
javaclasspath('./3party')
server = HandleServer(50011, 'foo');
Because standalone, >>edit(fullfile(prefdir,'javaclasspath.txt')) I would like to circumvent (it errors too), if i right click and add folder via context menu in file explorer it works. What am I doing wrong here, the 3party folder is on the dynamic class path and not shadowed, please help?
Second question is (if i use the context menu to add Server.m to fix above), inside Server.m it references Java class inside .jar file, which is not found although i add the jar in the app compiler wizard "files required to run..".
The import command looks like:
import io.github.jebej.matlabwebsocket.MatlabWebSocketSSLServer;
and the jar file contains a top folder 'io' and nested until the actual class 'MatlabWebSocketSSLServer.java', so the file exists inside the jar, what is wrong? The error is:
mcc -o test -W main:test -T link:exe -d /..foo../main/standalone/test/for_testing -v /..foo../main/main.m -a /..foo../main/3party -a /..foo../main/HandleServer.m
Compiler version: 6.4 (R2017a)
Dependency analysis by REQUIREMENTS.
Unexpected error while determining required deployable files. Compilation terminated. Details:
Error using getSymbolNames
Import argument "io.github.jebej.matlabwebsocket.MatlabWebSocketSSLServer" in MATLAB code '/..foo../main/3party/Server.m' cannot be found or cannot be imported.
This answer says it mcc -a should take care of it all, no need for addclasspath but not working:
https://de.mathworks.com/matlabcentral/answers/97072-how-should-i-include-a-jar-file-in-my-compiled-application-with-matlab-compiler-4-1-r14sp1

Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!