Run a java program inside Matlab with a input file.
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
luigi ventre
le 1 Déc 2021
Modifié(e) : Kojiro Saito
le 7 Déc 2021
Hi, I'm tring to run a java program from a matlab code. I already added the .jar file in the system static variables and I achived to lounch the progam. However I need to use a input file wrote inside matlab as a .txt file (or .dat dosen't matter). I'm using the system function:
system('java -jar mhclasses.jar');
system('java -jar javafoil.jar' );
where i can put the input file?
3 commentaires
Réponse acceptée
Kojiro Saito
le 7 Déc 2021
Modifié(e) : Kojiro Saito
le 7 Déc 2021
I'm not familiar with JavaFoil, but it seems that "Script" option allows input files. If you want to input data.txt, try this.
!java.exe -cp "java\mhclasses.jar" -jar "java\javafoil.jar" Script="data.txt"
Alternatively, JavaFoil has embedded sample java code in Embedding and you can use it in MATLAB.
javaFoilPath = "C:\Path\To\MH AeroTools\JavaFoil\java";
javaaddpath(fullfile(javaFoilPath, 'mhclasses.jar'))
javaaddpath(fullfile(javaFoilPath, 'javafoil.jar'))
import MH.JavaFoil.*;
jf = JavaFoil;
% Start JavaFoil embedding
jf.startEmbedded ;
jf.runScriptLine("Options.Country(0)");
% You can input using CreateAirfoil
%jf.runScriptLine("Geometry.CreateAirfoil(0,121,12,30,0.000,40.000,0,0,1)");
% It seems that you can input txt file
jf.runScriptLine("Geometry.Open('data.txt')")
jf.runScriptLine("Polar.Analyze(500000,500000,100000,-5,15,1,100,100,0,0)");
jf.runScriptLine("Polar.Save('polar.txt')"); % Save the result
% Close JavaFoil embedding
jf.exitEmbedded;
clear jf
Again, I'm not familiar with JavaFoil, and it is rather JavaFoil specific question than MATLAB, so if you have further question, I think it's better to ask in JavaFoil community.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!