I'm trying to create a function on Azure Function Apps that is given back a PDF and uses the python tika library to parse it.
This setup works fine locally, and I have the python function set up in Azure as well, however I cannot figure out how to include Java in the environment?
At the moment, when I try to run the code on the server I get the error message
Unable to run java; is it installed?
Failed to receive startup confirmation from startServer.
So this isnt possible at this time. To solve it, I abstracted out the tika code into a Java Function app and used that instead.
Related
I am trying to replicate on Azure Functions the example that is in Quickstart: Create a Go or Rust function in Java. I set up a couple of methods that respond to REST requests, and I bundled them as well as a Jetty server, that manages and routes the requests, into an executable Uber JAR. When I run java -jar handler.jar, an instance of a Jetty server is started, so I can navigate to http://localhost:8080/ping. I can achieve the same by using the JRE I have installed on my computer when using func start with the following host.json:
"customHandler": {
"description": {
"defaultExecutablePath": "java",
"arguments": ["-jar", "handler.jar"]
},
"enableForwardingHttpRequest": true
}
Now, I'm trying to deploy this app to Azure Functions. One possible way would be to create a custom image with the following Dockerfile:
FROM mcr.microsoft.com/azure-functions/java:4-java11-slim
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
COPY ["./functions", "/home/site/wwwroot"]
and start a function by using this image - I tried this and it works ok, but it seems to be quite inefficient to create a 1GB+ image, when the JAR I want to deploy takes up just a couple of MBs.
I was wondering, if there is a way to avoid this step? For example, push only the JAR and all the .json files to functions and use the default JRE, that is included when I create a Function App with the Java runtime stack? In other words, is it possible to achieve what I achieve locally when using func start, but use the JRE that is on azure instead?
The documentation ("If your handler requires operating system or platform dependencies (such as a language runtime), you may need to use a custom container.") is not that very clear about the topic.
Thank you!
Have a look at the Triggers and annotations paragraph of the Azure Functions Java developer guide.
In the function.json, set the scriptFile field to the (relative) location of your jar, and set entryPoint to the location of the method the Azure Function should execute. Then using the Azure Functions Core Tools, you can do func azure functionapp publish {function_app_name_in_Azure} --java to publish too the Function App in the cloud.
I need to create a Java application which sends some input parameters to a python script and sends some output back to my java application.
I cannot run the script in my java code using jython Or similar things as the python scripts are build on demand and I may need to add new scripts every now and then. So this should not impact my java app.
My java application will be running on a container and based on a few condition check it might have to select 1 of the py scripts from suppose 100 scripts and run it. And again the condition later on may change and a different script has to run at that time
I went through many websites and tutorials on the net but did not find anything relevant.
Has someone tried anything similar?
I am trying to communicate my Server with another Cloud service which speaks through a specific protocol that was developed based on Google Protocol Buffer.
I wrote a Java program in Netbeans which is able to read messages from this Cloud service, but these messages appear in my console in an unreadable format. I was said that I must have installed the appropriate protocol to interpret these messages.
So, I installed google protocol buffer for Java and Win:
https://github.com/google/protobuf/releases/tag/v3.5.0
Now, I am trying to use protoc commands in cmd to compile my Java program (which reads the input messages from cloud service) to be able to read the incoming data in understandable format.
Can anyone help me answer these two questions:
Real working example of using Protoc to compile a Java program?
Google says use this:
protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/addressbook.proto
https://developers.google.com/protocol-buffers/docs/javatutorial
But I am not able to get this syntax work
What output would this command generate and how/where can I use it to interpret the messages I am receiving in the Netbeans console (with my Java program created in Netbeans)?
Thank you!
I am trying to write java code to execute remote commands on an SSH, similar to the one in this library: Chilkat Android SSH Execute Remote Commands.
However, I do not know where to begin. I do not need to implement the entire library, I only need to be able to send messages from my computer to a device through a SSH using Java code. Specifically I want to implement the Connect, AuthenticatePw and quickCommand methods in the library.
My question is what do I need to learn in order to be able to write a java file that does this? I would appreciate any links to relevant tutorials.
I created an application that uses MediaRecorder, it creates a file in my application directory and records into it, it worked fine.
But later i decided to make a desktop version of it without sending it to the build server by following the instructions i found here
My app is working fine, but i don't think it does the recording, infacts it throws a null pointer exception and the file path it shows when i try to show it with a dialog is something like this file://homeaudioSample1410359700375. Which makes me know that it seems to behaving like it is running in simulator. So i decided to run the jar from the command prompt and what i got was an error: not supported in simulator. What is the solution to this as i want the app to also run on non-mobile platform, or is there no other way around this except sending it to the build server.
Media recorder isn't supported in the JavaSE port of Codename One.
You can use a native interface implementation for JavaSE support. Media is just really problematic for desktop Java...