Results 1 to 17 of 17
Like Tree1Likes
  • 1 Post By gimbal2

Thread: An error occurred while shelling out to javac, Matlab

  1. #1
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default An error occurred while shelling out to javac, Matlab

    I am trying to extract a jar file from Matlab code using javac from Library Compiler (java package).
    I have set JAVA_HOME to:

    Java Code:
    C:\Program Files\Java\jdk1.7.0_11
    and added to PATH:

    Java Code:
    C:\Program Files\Java\jdk1.7.0_11\bin.
    When I enter java -version in my console, I get java version jdk1.7.0_11 and running javac -version shows jdk1.7.0_11.
    However, it seems that matlab could not find javac, thus, I am not able to compile my .m code into a .jar file. When I tried to compile .m code I got the following:

    Java Code:
    Error: An error occurred while shelling out to javac (error code = -1).
    Unable to build executable.
    Executing command: ""C:\Program Files\Java\jdk1.7.0_11\bin\javac"
    This is the directory of my java bin folder and javac.exe exists : C\Program Files\Java\jdk1.7.0_11\bin\javac.exe? What should I check in order to correctly link Matlab to Java?
    Last edited by coolis; 01-26-2015 at 12:53 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: An error occurred while shelling out to javac, Matlab

    C:\Program Files\Java\jdk1.7.0_71\bin\javac

    For some reason it's looking for build 71, not build 11.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    My mistake, it is C:\Program Files\Java\jdk1.7.0_11\bin\javac in the error section.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    what happens when you try to invoke the literal command that the matlab shellscript is using?

    Java Code:
    C:\Program Files\Java\jdk1.7.0_11\bin\javac -version
    If that works as expected: historically windows shell scripts have had trouble with paths that have a space in it; you may be running into one of those historic scripts. The generic workaround is to install the JDK in a path that has no spaces, such as "c:\java\jdk7".
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    I can't run C:\Program Files\Java\jdk1.7.0_11\bin\javac -version as Matlab command. The weird is that before 3 weeks I had installed a java version in Program Files and the java package worked fine. After a windows update, I couldn't compile my code to jar file.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    What does that mean, "can't run". What error do you get?

    Is there even such a folder on your harddrive, "C:\Program Files\Java\jdk1.7.0_11" ?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    Yes is the path where I isntall jdk. I am confused of what you propose to execute in matlab shell. I tried to run exactly the following C:\Program Files\Java\jdk1.7.0_11\bin\javac -version and I got:

    C:\Program Files\Java\jdk1.7.0_11\bin\javac -version
    |
    Error: Unexpected MATLAB operator.

    However I noticed the existence of a java.m file. Maybe this is the file that cause the whole confusion.
    Last edited by coolis; 01-26-2015 at 05:26 PM.

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    I didn't even know matlab had any kind of built-in shell, a big communication error.

    invoke that command on the command prompt, where you previously only invoked the 'javac' command without any path. What I'm trying to see is what happens when you literally invoke what matlab is instructed to invoke.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    Ok what am I supposed to do then?

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    I get a bit cranky when I say what to do and then I get the question "so what do I do".
    DarrylBurke likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: An error occurred while shelling out to javac, Matlab

    Originally you had an error message

    Error: An error occurred while shelling out to javac (error code = -1).
    but we don't know what the command was for which the error occured. What gimbal2 is suggesting is that you take that command (whatever it was), execute it on the command line, and say what happens.

  12. #12
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    javac -version in console returns javac 1.7.0_11. If I write the whole proposed command C:\Program Files\Java\jdk1.7.0_11\bin\javac -version it gives me C:\Program is not recognised an an internal or external command.

  13. #13
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    I tried to install java to C:\Java. I set setenv('JAVA_HOME','C:\java'); setenv('PATH','C:\java\bin'); from matlab console. When I tried to deploy jar file I got:
    Error: An error occurred while shelling out to javac (error code = -1).
    Unable to build executable.
    Executing command: ""C:\java\bin\javac

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    so how do you "deploy the jar" ?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  15. #15
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    By using the MATLAB compiler APPS, and choosing as a type Java Package.

  16. #16
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    13

    Default Re: An error occurred while shelling out to javac, Matlab

    The only idea I have left is that you have the wrong Java JDK. Perhaps you have a 64 bits JDK and matlab requires you to have a 32 bits JDK. But this is starting to look a lot like a matlab specific problem and this is not a matlab forum.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  17. #17
    coolis is offline Member
    Join Date
    Jan 2015
    Posts
    9
    Rep Power
    0

    Default Re: An error occurred while shelling out to javac, Matlab

    From the deployment tool I am able to extract console application and Windows Stand Alone application, however, I could not compile it to either Java Package and C++ Shared library

Similar Threads

  1. Replies: 0
    Last Post: 08-16-2014, 01:36 PM
  2. Replies: 5
    Last Post: 10-19-2010, 05:57 AM
  3. Error Occurred Executing Command Line Solution
    By RahulKhire in forum Eclipse
    Replies: 1
    Last Post: 09-10-2008, 02:38 PM
  4. Replies: 3
    Last Post: 04-10-2008, 10:01 AM
  5. an internal error occurred during refresh
    By christina in forum Eclipse
    Replies: 1
    Last Post: 08-06-2007, 10:37 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •