Apache Maven On Ubuntu
-
October 20, 2016
-
Nirupama Shree
How to install Maven on Ubuntu:
Search Maven Package
In a terminal, run apt-cache search maven, to get all the available Maven Package.
The maven package always comes with latest Apache Maven.
Install it
Run command sudo apt-get install maven, to install the latest Apache Maven.
It takes few minutes to download, patient.
Verification
Run command mvn -version to verify your installation.
The Apache Maven is installed successfully.
That is all for this article, in case you need Salesforce Implementation Services for any Salesforce related work, then please feel free to reach out to sales@girikon.com
Mobile application development is a set of processes and procedures involved in writing application software for small, handheld or wireless computing devices such as smart phones, PDAs, EDAs or tablets.
In Mobile App development process, Mobile User Interface (UI) Design is also an essential part considering constraints & contexts, screen, input and mobility as outlines for design.
One critical difference between Mobile application development and traditional software development, is that mobile applications (apps) are often written specifically to take advantage of the unique features a particular mobile device offers. So, the development should be centric on optimum performance for a given device, even when application is interacting with external applications.
In such a scenario (interaction with external world) REST API is the best option. REST stands for Representational State Transfer & it is a simple stateless architecture and a communication approach that generally runs over HTTP.
REST is preferred over SOAP (Simple Object Access Protocol) for development of web services as the latter is quite heavyweight and consumes comparatively greater bandwidth. Owing to its decoupled architecture and lighter weight communications, REST usage is very prevalent in mobile applications. It is a better fit for use over the Internet and easily binds with cloud-based APIs like those of Amazon, Microsoft, and Google.
Here is an example to ” Create REST API client Async in android ”
1. This is AsyncTask which will run in background with affecting the UI.
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import android.os.AsyncTask;
public class CallRestApi extends AsyncTask
{
public AsyncResponse delegate=null;
public CallRestApi(AsyncResponse asyncResponse) {
delegate = asyncResponse;//Assigning call back interfacethrough constructor
}
@Override
protected void onPreExecute() {
// if you want, start progress dialog here
}
@Override
protected String doInBackground(String… params)
{
String urlString = params[0];
String resultToDisplay = “”;
InputStream in = null;
try
{
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();
in = new BufferedInputStream(urlConnection.getInputStream());
resultToDisplay = convertStreamToString(in);
in.close();
} catch (Exception e)
{
System.out.println(e.getMessage());
return e.getMessage();
}
return resultToDisplay;
}
@Override
protected void onPostExecute(String result) {
// if you started progress dialog dismiss it here
delegate.processFinish(result);
}
private static String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try
{
while ((line = reader.readLine()) != null)
{
sb.append(line + “\n”);
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
return sb.toString();
}
}
2. Create Interface for getting result.
This is for getting AsyncResponse in the activity class
public interface AsyncResponse {
void processFinish(Object output);
}
3. Call REST API client from activity class
private void functionName(String newUrl)
{
CallRestApi client = new CallRestApi(new AsyncResponse()
{
@Override
public void processFinish(Object output) {
String responseResult = ((String) output);
});
}
try
{
client.execute(new String[] { newUrl });
}
catch (Exception e)
{
e.printStackTrace();
}
}
Enjoy 🙂
Avinash
That is all for this article, in case you need Salesforce Implementation Services for any Salesforce related work, then please feel free to reach out to sales@girikon.com
Recently i created a Penalization calculator which is written in Perl [.exe] language to calculate panel required to manufacture a printed circuited board. I did it for one of our customers. The output screen for this calculator looks like below:
I wanted to integrate the same penalization calculator in one of the projects which is written in java.
So I code like mentioned below to call exe in java.
package panelcalculator;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class PanelCalculator {
public String calculate(String strParms)
{
String result = “”;
try {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(strParms);
InputStream inStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
String data = “”;
while ((data = reader.readLine()) != null) {
result += data + ” “;
}
reader.close();
inStream.close();
process.destroy();
}
catch (Exception e)
{
result = e.toString();
}
return result.trim();
}
public static void main(String arg[])
{
PanelCalculator pc = new PanelCalculator();
String result = pc.calculate(“D:\\MyWebapp\\PanelizationCalculator\\PanelCalculator.exe PanelX=12 PanelY=18 NLayers=2 Spec=\”IPC-6012 Class 2\” BoardX=12 BoardY=2.25 Spacing=0.2 LaserDrill=N Flex=N Impedance=N ImpSingleEnd=0 ImpDiff=0 EdgePlating=N”);
if(result!=null){
System.out.println(result);
}
}
}
And finally i got output like following, exactly the same as I wanted:
UsableX=10.2 UsableY=14.6 MaxUp=4
Thank you.
Narendra