Can a scala program be running on a browser with disabled java plugin (as scala is compiled to a jvm bytecode)? In other words: is the jvm disabled provided the java browser plugin is disabled?
Or does Scala run server-side and I am confused?
If I estimate it correctly, you can have both: Server-side and Client-side.
In case you want to use it on the server, it's called a Servlet and compiled to a JSP-application.
In case you want to use it on the client, it's an Applet and runs in the JVM. And that's what the user disables in his browser-settings.
As far as I know it, java and scala compiles to the same type of bytecode which is executed by the JVM.
Therefore, you cannot use neither Scala nor Java if the user has the plugin disabled. The browser cannot distinguish between these two.
The only java program which "runs in a browser" is an applet; any class extending java.applet.Applet will serve this purpose. As a scala class can extend a java one, it is therefore perfectly possible to write an applet in scala.
However, this cannot run if java is disabled in the browser as scala runs on the Java Virtual Machine. (In fact, there's no difference between a compiled scala program and a compiled Java program - they are both bytecode, which is run on a JVM)
Applets are not particularly common however, and most scala code will be server-side in practice. When you see people talking about scala and the web, they are most probably talking about Lift, which is a (server-side) web-framework for Scala.
Scala is almost always run on the server or as a normal desktop "java" application.
I suppose it would work perfectly well as an applet, if it doesn't add any confusion to the security model, but if applets are disabled I presume you can't run any JVM code at all.
Regarding Lift, the server side runs Scala, but the client side runs automatically generated Javascript, which does not need the jvm.
Related
Can Python invoke the Java Framework?
I want to know whether a Python project can invoke a Java Framework, I find a Java Framework in GitHub, whether I can use it in my Python project?
Jython
Jython is one method of calling Java from python -- actually, you run your Python inside Java JVM. This gives you access to almost any Java that runs on JVM, but comes with many limitations.
Because Jython is running python inside the JVM, this gives you acess to almost any Java library. However, you are very restricted in what Python you can use: you can only use Python 2.7, and can import pure Python libraries only (compiled Python libraries with C will not run on Jython).
For an example of a project that uses Jython: Processing.py runs on Jython in order to access the Processing Java API and its ecosystem of Java libraries.
https://github.com/jdf/processing.py
Note that Jython 2 and its docs are quite old, and that the developers are uncertain if / when Jython 3 will be released.
https://github.com/jython/jython3
py4j
py4j is a different approach -- it is "A Bridge between Python and Java" and lets native python code access separate Java running in a separate JVM. Note however that the python and Java code must be running in parallel and communicating through a gateway interface. This is communication between separately running processes -- you are not spinning up a JVM from Python or inside Python.
For example: on the JVM side pass myObject to a new GatewayServer(myObject); on the Python side create a JavaGateway() Python object and use it to communicate with the Java myObject.
Normally Python and Java have their own interpreters/VM's and cannot be shared. It is possible to use Jython but has limitations (fe. python version and support/compatibility with other python packages).
The interpreter and JVM do not match: Java has strict typing, python not. Java compiles and run, python is an interpreter and can change code in runtime (if you want). These are extra challenges why putting all in a same environment is very complex.
There are possibilities like a client/server architecture, but the feasability depends on the level of the framework.
Most of the time low level frameworks are optimized to run directly inside your application process. Any loose coupling will introduce performance and security and compatibility issues. Just think about how reflection will work or multiple inheritance.
If it is a high level framework (fe able to run stand alone) it is more feasable to use some sort of client/server. But still you have to develop a lot for it.
Industry standard is just to implement the framework of your desire in the language you want, then you can get also all the benefits of your platform.
First I'm sorry because my English language is poor.
But is my question.
How is to compile and run application written in c/c++ and under NDK on Android OS??
Does it application compiling and running in Dalvik or ART?
Or independent is that VM??
In the case of programs written in other languages, how is it?
For example (C# in Xamarin) or (Delphi in Firemonkey) or (Basic) or (Python)? Thanks a lot for my question answers.
Please, do a research.
Basically yes, almost all non native solutions use some kind of VMs. For example Xamarin use MonoVM for Android platform. The C# code is compiled into CIL, which is executed by the Mono execution environment. This execution environment is run side by side with the Java Virtual Machine, which means the applications are not executed the same as native application, however they are executed in a equivalent way. This means that the performance is tied to MonoVMs implementation.
MonoVM is packaged with the application, which means that Xamarin Platform applications can be installed in the same way as a native application, without any additional installs.
I read that DukeScript, a technology meant to bring Java to every client without the need of a plug-in.
Can this technology used as an applet replacement?
In geneneral I'd say yes.
Is there a particular reason why you would choose to use java applets in the past, meaning: did they need to do things like accessing the hardware and/or file system?
If your applet would do nothing more than what JavaScript would be able to do, then yes, you can definitely look at Java to to JavaScript solutions like GWT or DukeScript. They're quite different: one translates Java source code to JavaScript, the other one uses Java VMs written in JavaScript in order to run bytecode. Regardless, they're subject to the same limitations, when deployed to standard browsers. DukeScript though can be packaged up as a standalone app, running inside the JavaFX browser or as a native app on mobiles, therefore it can do more than standard JavaScript can do.
ok, So i searched net for the possible implementation but all that I managed to find is Django projects implementation on Java platform through Jython. But I want to do the reverse, i.e. implement/integrate java project ( which in my case is SAIKU server ) on Django platform.
The question being, is it possible, and if yes, then kindly point me to the solution.
Thanking in advance =)
For your specific requirement, I would suggest using RESTFul API to access the Saiku Server.
However if you need to run Java Classes from Python.
Here are the options available for you:
JCC -- a C++ code generator for calling Java from C++/Python. It produces producing Python extensions which communicate via JNI with a Java virtual machine. As it implies, this would require compilations of every possible call. However this project is backbone of PyLucene project.
CodeMesh. C++ code generator for Java.
Py4J Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine.
JPype allow python programs full access to java class libraries. It is done through interfacing at the native level in both Virtual Machines. However there are no recent development in this front.
In general, having an loosly coupled integration through REST or RCP would be easy to maintain than tightly coupled JNI based implementation.
There's no way to run Java within the Python runtime (which is what it sounds like you want). There are Java to Python "translators" available, but they're terrible. Honestly, if you need a Java server and Django to sit inside the same process for some reason, Jython is the way to go.
There are lots of options outside of that though, off the top of my head:
Implement Python bindings for your server (See PyLucene for an example)
Implement a socket server within your Java server that Python can talk to directly
By using the JRE or some other runtime environment, is it possible to compile Java code on a web server such as Apache or Nginx?
Specifically, I would like to have a web application that would accept user input (Java code), and when the user hits run, it would compile the Java into Java Byte code and display the result, like Eclipse does.
Does this sort of technology even exist?
Does this defy the logic of compiled languages?
Thank you for your time in advance.
Amicably,
James
The server running Apache would also need a JDK. You could easily write the input to a file, compile it, run it, and display the results to the user. This could be done with a CGI script, or a Java EE app or similar, running in Tomcat. A JDK will be required, a JRE will not suffice.
Consider the potential security risk with this, though. Depending on what the program actually does, it could result in problems on your machine or others.
Of course this is possible. But you need a JDK, and some server side scripts (PHP, Ruby, Python, Java ...) which takes the source code as input and calls the Java compiler to compile the code.
What you have to consider are the security implications. Every user could then upload code, which would be executed on the server. So you have to make sure, that the code runs in a sandbox.
There are several websites that do this. One that I've used is at http://www.ideone.com.
You can reproduce this with the JDK and various scripts or you can write your own compiler from scratch. Either way, you need a compiler of some kind to actually compile the code.