ScriptCraft

ScriptCraft

14.6k Downloads

can't find method java...

johndgreene opened this issue · 8 comments

commented

i'm following the book 'A Beginner's Guide to Writing Minecraft Plugins in JS'. i followed instrux to install java, canarymod, scripcraft. i got the server to start and scriptcraft is running. it works for commands such as

js 3+2 (it returns 5.0)

however, when i follow the instrux on page 31

js healthMessage = 'You have ' + hearts + ' health remaining', i get an error - can't find method java.etc. apparently when i ask js to write a line of text it looks for a java file and does not find it. i don't know anything about java or the OS on my mac, so i don't know how to help my mac find the method that allows the string to be displayed.

if anyone knows how to show the mac where the right java files are, please let me know

thanks!
j

commented

the exact error message is
[ScriptCraft] [ERROR]: Error while trying to display result: 123, Error: InternalError: Can't find method java.lang.String.valueOf(). (#191)

(above error message is in response to js '123')

commented

Can you type the following command at the terminal window?

java -version

And let me know what the result is? I recommend updating Java to version 8 if you haven't already done so. http://www.oracle.com/technetwork/java/javase/downloads/index.html

commented

Thanks very much for your response!

I ran version in the terminal window and it says

Java version "1.6.0_65"

That sounded wrong (or bad) so I went to 'latest Java' online and it told me how to check whether this Mac has the latest Java. It said go system preferences and go to Java icon and use the update tab. I did that and in there it says 'your system has the recommended version of Java.' Then it says Java 8 update 51.

It sounds like maybe I have two javas? And one is way down rev?

J

Sent from my phone

On Jul 24, 2015, at 12:22 PM, Walter Higgins [email protected] wrote:

Can you type the following command at the terminal window?

java -version
And let me know what the result is? I recommend updating Java to version 8 if you haven't already done so. http://www.oracle.com/technetwork/java/javase/downloads/index.html


Reply to this email directly or view it on GitHub.

commented

i found a fix on line.  here is a paste (below)
the oracle installer leaves the path to the old java and it is apparently still on the mac somewhere.  i followed the instrux below and it fixed the problem.  now i can issue js commands that ask for a script, such as js '123' and it works
thanks for your help 
j

|
|
|

sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
| shareimprove this answer | edited Feb 27 at 19:55Anton Rudeshko
3681314 | answered Feb 14 '13 at 12:50Ákos
1,385247 |

|
| |
|
|    |   |

| I've done this on a few machines and I always forget how! :) Thanks for this. I'm now running java 7 in osx 10.8.4. –  BingeBoy Jul 19 '13 at 4:01 |
|
| 18 |   |

| Here is the command: sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin –  Viktor Lexington Sep 11 '13 at 4:46 |
|
| 11 |   |

| |

|

|

  From: Walter Higgins <[email protected]>

To: walterhiggins/ScriptCraft [email protected]
Cc: johndgreene [email protected]
Sent: Friday, July 24, 2015 12:22 PM
Subject: Re: [ScriptCraft] can't find method java... (#258)

Can you type the following command at the terminal window?java -version
And let me know what the result is? I recommend updating Java to version 8 if you haven't already done so. http://www.oracle.com/technetwork/java/javase/downloads/index.html—
Reply to this email directly or view it on GitHub.

commented

oops - just wrote closing comment in above comment

commented

i'm closing this issue since the fix above worked for me. the basic problem was that the oracle java installer did not modify the path to point to the new java when i installed java 1.8 on the mac. (and left 1.6 on there). so canarymod was finding the old java 1.6 that apple had on the mac. for some reason system preferences shows the new java (1.8) even though the path is still to the old java. the fix was to change the path called out in some mysterious file. the guy who provided the fix was kind/wise enough to include the necessary commands you have to type in terminal to change the path callout.

commented

it's fixed!  see comments i posted on github.  
thank you very much for your help - i was getting discouraged and your suggestion about version put me on the right track.  now i've got script craft running and my son and i are able to move forward to the next few chapters of your book!
j
From: john greene [email protected]
To: walterhiggins/ScriptCraft [email protected]
Cc: walterhiggins/ScriptCraft [email protected]
Sent: Friday, July 24, 2015 10:08 PM
Subject: Re: [ScriptCraft] can't find method java... (#258)

i moved the java plugin folder in library/internet plugins to the trash and emptied trash.  mac said no java.  i reinstalled java from oracle.  it said successful.  system preferences says (again) we have java version 8. update 51.  in the java panel it says java 1.8.0_51.  but in terminal in response to java -version it still says version 1.6.0_65.  i searched the mac trying to find anything with 1.6.0_65, and only found a script file, apparently by you (wph) that seems to be something to deal with apple java 1.6.0_65 not handling scripts right (which is my problem).  but i can't figure out why terminal thinks java version is 1.6.0_65.  still stuck.
j

 From: John G <[email protected]>

To: walterhiggins/ScriptCraft [email protected]
Cc: walterhiggins/ScriptCraft [email protected]
Sent: Friday, July 24, 2015 9:23 PM
Subject: Re: [ScriptCraft] can't find method java... (#258)

Thanks very much for your response!
I ran version in the terminal window and it says
Java version "1.6.0_65"
That sounded wrong (or bad) so I went to 'latest Java' online and it told me how to check whether this Mac has the latest Java. It said go system preferences and go to Java icon and use the update tab. I did that and in there it says 'your system has the recommended version of Java.' Then it says Java 8 update 51. 
It sounds like maybe I have two javas? And one is way down rev?
J

Sent from my phone

On Jul 24, 2015, at 12:22 PM, Walter Higgins [email protected] wrote:

Can you type the following command at the terminal window?java -version
And let me know what the result is? I recommend updating Java to version 8 if you haven't already done so. http://www.oracle.com/technetwork/java/javase/downloads/index.html—
Reply to this email directly or view it on GitHub.

commented

i moved the java plugin folder in library/internet plugins to the trash and emptied trash.  mac said no java.  i reinstalled java from oracle.  it said successful.  system preferences says (again) we have java version 8. update 51.  in the java panel it says java 1.8.0_51.  but in terminal in response to java -version it still says version 1.6.0_65.  i searched the mac trying to find anything with 1.6.0_65, and only found a script file, apparently by you (wph) that seems to be something to deal with apple java 1.6.0_65 not handling scripts right (which is my problem).  but i can't figure out why terminal thinks java version is 1.6.0_65.  still stuck.
j
From: John G [email protected]
To: walterhiggins/ScriptCraft [email protected]
Cc: walterhiggins/ScriptCraft [email protected]
Sent: Friday, July 24, 2015 9:23 PM
Subject: Re: [ScriptCraft] can't find method java... (#258)

Thanks very much for your response!
I ran version in the terminal window and it says
Java version "1.6.0_65"
That sounded wrong (or bad) so I went to 'latest Java' online and it told me how to check whether this Mac has the latest Java. It said go system preferences and go to Java icon and use the update tab. I did that and in there it says 'your system has the recommended version of Java.' Then it says Java 8 update 51. 
It sounds like maybe I have two javas? And one is way down rev?
J

Sent from my phone

On Jul 24, 2015, at 12:22 PM, Walter Higgins [email protected] wrote:

Can you type the following command at the terminal window?java -version
And let me know what the result is? I recommend updating Java to version 8 if you haven't already done so. http://www.oracle.com/technetwork/java/javase/downloads/index.html—
Reply to this email directly or view it on GitHub.