Scala weaving in existing Java EE projects?

I have a lot of questions about scala. I did a bit of reading and searching on Google and SO'ing and did not find any reliable answers. I am not yet at the stage of experimentation / prototyping, so I thought that I could just ask my questions and get some expert knowledge so that everyone could share. Thanks in advance!

What is scala.exe used for? Can someone give a summary of what scala.exe does differently than java.exe? Is there any runtime magic in scala.exe other than providing an interpreter shell?

( UPDATE ): scala.exe. Scala comes with a simple script launcher package, scala.bat (or Scala on * nix). The Scala workbench is java.exe with the standard Scala library banks in CLASSPATH.)

Can I associate Scala code with an existing java program if I run the process using java.exe? If so, should my CLASSPATH change the link to the standard Scala library containers? Also, if I run with java.exe, are there any new javaagent parameters needed for reference in Scala code? Is there a way to include Scala code in banks in my existing web application .war file (or in WEB-INF / classes) and run it?

And vice versa, if scala.exe is required to execute scala + java code in my Java EE Java application server, can scala.exe take all my esoteric -XX parameters: InsertYourCrazySunPerfSwitchHere JVM?

Finally, does the new Scala code incorporate into the existing Spring Framework + JSF2 web application, for example, trying to insert a circular binding into a square hole? I see long lists of web frameworks developed for Scala that are available, but I wondered how smooth or inconvenient Scala will play with commodity tools like JSF2. Are these Scala-based web frameworks a by-product of non-Java developers who migrate to the Scala community and want to recreate their Scala jour framework? Or, is there something inward about how JSF2 is designed in such a way that when I became an expert at Scala, I would see that it was a messy mess trying to mix two and wasted my time?

+4
source share
1 answer

You asked a lot of questions. I will try to address them all, one at a time.

Question:

What is scala.exe used for? Can someone give a summary of what scala.exe does differently than java.exe? Is there any temporary black magic in scala.exe other than providing an interpreter shell?

scala.bat can perform several actions depending on the arguments:

  • it can run an interpreter shell
  • he can execute the scala script file
  • it can execute a compiled Scala binary from the classpath
  • it can execute jar file

When running binaries, scala.bat simply calls java.exe with scala -library.jar added to the classpath. There is no magic.

Question:

Can I associate Scala code with an existing Java program if I run the process with java.exe? If so, should my CLASSPATH change the link in the standard Scala library libraries? Also, if I run java.exe, any new javaagent parameters needed to reference the scala code?

All Scala binaries are simple jars. The only difference is that they require a Scala runtime library (scala -library.jar). Therefore, when you start with java.exe, you simply follow the steps that you take when you start the jar with dependencies. Again, there is no magic and no additional switches.

Question:

Is there a way to include Scala code in banks in my existing network .war file (or in WEB-INF / classes) and run it?

Scala banks are java banks, so you can consider them as such.

Question:

Finally, incorporates new Scala code into an existing Spring Web application Framework + JSF2, for example, trying to set a circular binding in a square hole? I see long lists of web frameworks designed for scala which are available, but I wondered how smooth or inconvenient scala will play with commodity tools like JSF2. Are these scala web frameworks, by-products of non-Java developers, the Scala community and wanting to recreate their framework in the Scala language? Or, is there something inherent in how JSF2 is designed in such a way that as soon as I became an expert at Scala, I would see that it was a messy mess trying to mix the two and wasted my time?

Using Java libraries from Scala is at least as simple as using them with Java and often much smoother. Scala, on the other hand, is much richer than Java. This way you will feel that Java libraries are missing as soon as you get used to scala.

+4
source

Source: https://habr.com/ru/post/1369201/


All Articles