Matlab - Build JAR for `javaclasspath`

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Matlab - Build JAR for `javaclasspath`



After following several of examples like this Example 1 and Example 2, i am still unable to build my own JAR Java file for MATLAB (R2014).



For the Example 2, I can successfully create classes from the given JAR after adding myHelloArchive.jar it to the javaclasspath.


myHelloArchive.jar


javaclasspath



But from the given code for HelloWorld.java:


HelloWorld.java


// HelloWorld.java
public class HelloWorld{
public HelloWorld(){
setVersion(0);
}
public static void main(String args){
System.out.println("Hello World!");
}
public void setVersion(int aVersion){
if( aVersion < 0 ){
System.err.println("Improper version specified.");
}
else{
version = aVersion;
}
}
public int getVersion(){
return version;
}
private int version;
}



by running these system commands successfully, having both javac.exe and jar.exe in the system command path, and having HelloWorld.* in the current MATLAB folder:


javac.exe


jar.exe


HelloWorld.*


javac HelloWorld.java
jar cf HelloWorld.jar HelloWorld.class
>> javaaddpath('HelloWorld.jar')



I cannot create a class:


>> HelloWorld
Undefined function or variable 'HelloWorld'.



The running system command always works for the default main():


main()


java -jar HelloWorld.jar
HelloWorld!



Why the provided JAR suceeds and the JAR file I compile from the given code nor my own JARs do not work?



I am positive I built a JAR file previously from the Eclipse IDE, but for some reason I neither can reproduce that.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to scale/resize CVPixelBufferRef in objective C, iOS

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

SVG with two text elements. When one resizes due to textLength - how to resize the other one to the same character size