I have a java application, a scala script and a jar library.
The Java application is a Jframe application.
THe scala script simply adds a button to a JFrame.
The jar library is just a normal java class contains a HashMap<String, JFrame>.
I imported this jar file to my java application and my scala script also has reference to it.
What I need to achieve is when the java application starts, it set the HashMap <"main",frame> and then execute the scala script. the script reads the HashMap and retrieve the JFrame from the Hashmap and then add a button to the retrieved JFrame.
The java program successfully put the jframe into the Hashmap. I use Runtime.getRuntime().exec to run the scala script but the script reads "null" from the Hashmap.
Is this because the scala script is running in a separate process? please could anyone advise how could achieve what I need? Thanks
Thanks. The reason why I did not use scala class directly is because I want to make the Java application configurable.. i.e. if the scala script exists in a certain directory, the java program executes it and then the scala script adds a button to the java application. if the script does not exist in the directory, the java program will not do anything...
I'm not convinced that Scala's a great scripting language, though--is there a particular reason you want to script in Scala rather than a better-supported language like JavaScript, Groovy, etc.?
yi sun
Greenhorn
Joined: Aug 08, 2010
Posts: 6
posted
0
Thanks David, I will have a look at the two links..
yi sun
Greenhorn
Joined: Aug 08, 2010
Posts: 6
posted
0
I've got it work using java standard scripting engine and javascript. the scala scripting engine in the above link does not seem to work properly...
Thanks David
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32704
4
posted
0
And welcome to JavaRanch
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.