Is there a way to transfer non-string parameters from JavaScript to a Java .jar file?

In my AngularJS application, I want to call a .jar file to handle the uploading of images/files. The idea is for Angular to send blob data (image information) to the .jar, along with the folder name where the image should be stored.

My Java method would require 2 parameters - one of blob type and one of string type. So how do I pass these parameters to the Java .jar file? I prefer not to use servlets for image upload, and instead I am thinking of creating a simple custom upload class in Java and packaging it into a .jar file.

However, a new question arises - how do I pass non-string parameters to the main method of a Java class that only accepts String args[]? My method needs parameters as well. This means that, if I understand correctly, the main method should receive parameters from JavaScript and then pass them to the appropriate method. Is this correct?

How can I accomplish this? Perhaps an example with some code would help?

Answer №1

In your Java application, you have the flexibility to convert the data to any desired format once you have obtained them as strings. However, it raises the question: what is the reason for utilizing Java on the client side?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Iterate through a collection of objects and organize the data in a specific way

Within the data structure of my API response, I am attempting to iterate through an array of objects under the items key. Each value inside these objects needs to be formatted based on the corresponding format type specified in the header key. To assist wi ...

The Angular Chart fails to refresh when data is modified

I am facing an issue with my Angular Chart bar not updating properly after retrieving JSON data from a servlet on an ng-click event. Although the $scope is updated, the chart does not reflect the changes. Is there a way to manually redraw the chart? I coul ...

Steps to eliminate the select all checkbox from mui data grid header

Is there a way to remove the Select All checkbox that appears at the top of the checkbox data column in my table? checkboxSelection The checkboxSelection feature adds checkboxes for every row, including the Select All checkbox in the header. How can I ...

Sending data from a controller to a service in Angular

Currently, I'm facing an issue while attempting to transfer a parameter from a controller to a service in Angular. Let's start with the controller code snippet: angular.module('CityCtrl', []).controller('CityController',[&apo ...

Adding a String into a byte array at a specific position in Java

Is there a way to insert a string value into specific indexes within an existing byte array? For example, how can I achieve this? byte [] sector = new byte[SECTORSIZE]; String str1 = "Sector 0, Record 0"; //I need to add str1 to the 'sector' arr ...

Javascript problem with closing the browser window in Selenium WebDriver

Here are a couple of inquiries: Firstly: Is there a method to initiate the browser on a specific URL (instead of about:blank) while also setting the history length to 0 when starting on that URL? Secondly: I suspect this question is related to the one me ...

TemplateUrl cannot be located within the AngularJS MVC framework

Hey there, I've been diving into tutorials on Angular without the Asp.net Core part. Currently, I'm stuck at a point where I need to include partial HTML in my application using this method: Main module (function(){ "use strict"; angula ...

Launching a program through a web browser - a step-by-step guide

I am looking to create a specific sequence of events: A web browser opens, and a user logs in (the exact action is not crucial) The user is then redirected to a new page where another program should automatically open This process is similar to what happ ...

The Vue computed property is failing to retrieve the data it needs

I'm having trouble with the computed() property not retrieving data. Data was initialized in the created() property. Am I missing something here? Any guidance on how to resolve this issue would be greatly appreciated. const randomPlayers = { temp ...

using the useEffect hook to create a loop that runs infinitely

For my project, I am working on updating data in firebase. The issue that I'm facing is that the data seems to be constantly looping, causing potential crashes. Is there a way to stop this loop and prevent any crashing? import "./App.css"; ...

Personal Information Management

After making a request for stormpath user custom data, I used the following code: res.render('home', { title: 'home', user: req.user.customData, }); Instead of receiving a JSON object of custom data as expected, a URL ('') ...

What could be causing my CSS/Layout to alter once AJAX/JavaScript has been executed?

When the user clicks, an AJAX call is made to retrieve data from a third-party API. The frontend/layout renders correctly before this action; however, after the data is fetched and displayed in the frontend, the layout changes. Upon debugging multiple tim ...

providing numerous values for a thymeleaf attribute

I am facing a challenge where I need to assign multiple values to a Thymeleaf attribute. My view page consists of a mix of Angular, Thymeleaf, and Spring MVC. <div id="zipLookup" ng-controller="AddressManagementCtrl" data-th-attr="data-data=*{primary.z ...

Utilize Jquery to easily interact with RadComboBoxes

Is there a way to capture all RadComboBoxes change events in JQUERY for ASP.NET? $("input[type='text']").Change(function() { alert('changed'); }); In this example, I am specifying the input type as "text" because RadComboBoxes hav ...

Tool to track character limits in multiple text fields

I'm facing a challenge with a form that includes 3 text areas, a copy button, and a reset button. My goal is to concatenate all the characters in the text areas to get a sum which will be displayed next to the copy/reset button. The character limit is ...

Dynamic animations with RaphaelJS - Creating animated connections

I recently came across a similar project here: My current project involves animating boxes by clicking a button. While I am able to move the boxes around smoothly during animation, the issue is that the connections between them do not move along. Is there ...

Removing commas and non-numeric symbols from a string using JavaScript

Stripping both a comma and any non-numeric characters from a string can be a bit tricky, especially with RegExs involved :). Is there anyone who could provide assistance on how to achieve this? I need to remove commas, dashes, and anything that is not a ...

Is it feasible to incorporate a third-party JavaScript file into a React application?

I have a JavaScript file from a previous MVC project that generates a basic table using ExtJS. Currently, I'm working on developing a new React application with a navigation bar and sidebar. My goal is to explore the possibility of importing the exis ...

Adding extra spaces between quote marks in a JSONObject

Currently, I am constructing a JSON string to be sent to my web service. However, as one part of this string comes from user input, there may be double quotes involved. To address this potential issue, I am attempting to escape these characters. String st ...

What is the correct method for verifying the presence of a field in JavaScript (or its frameworks)?

Is there a better way to rewrite this computed method in JavaScript to handle cases where a field may not be available? computed() { isVerified() { return this.name.info.is_valid; } } I can make it less verbose, but I want it to still functi ...