Posts

Showing posts with the label java

How to stop and start Appium server programmatically using Java?

How to stop and start Appium server programmatically using Java? How can I perform launching and stopping my server using Java code? Currently I am doing this process manually. Refer my blog link - happyautomation.blogspot.in/2015/01/… – Shekhar Swami Jan 13 '16 at 5:04 i reffered ur blog it is showing errors ---- Starting appium server ---- ---- Appium server started Successfully ! ---- 'C:/Program' is not recognized as an internal or external command, operable program or batch file. ---- Stoping appium server ---- ---- Appium server stopped Successfully ! ---- ERROR: The process "node.exe" not found. – sameer joshi Jan 13 '16 at 7:19 Kee...

I am not able to create groovy project

Image
I am not able to create groovy project I have used different approaches- My system has jdk 1.8.1. I tried installing Eclipse (oxygen and photon), Java programs are running fine but when I am installing groovy plugin from Help -> Install new software, it's not running. Then I tried installing different IDE that is NetBeans, here also I am not able to create project. Error: Warning | Unrecognized flag: non-interactive. Error | Specify an application name or use --inplace to create an application in the current directory You need to provide more information on what you did in Eclipse, and what the exact problem is with setting up Groovy. Just saying "it's not running" is insufficient. – skomisa Jul 1 at 18:28 Also, since you are asking two distinct questions in the post above it would be appropr...

How to create an adhoc network between laptops in java?

How to create an adhoc network between laptops in java? I want to create an adhoc between labtops were they will communicate using wireless communication. I will use java for this but still I do not know how to start.. I think I'll have to use sockets for the connections right? How will a laptop notice other laptops in its local network or the other way around? Do i need a server to handle the communication between laptops? Another thing, how to broadcast a message from one laptop to other laptops in the network? Please reply as soon as you can. Any help will be appreciated. Thanks in advance. Do you explicitly want to create the adhoc network in java on your own? I mean, you can use the existing application/services to create the network. Once the network is on, you can communicate between them as you would do on a normal LAN. – Vikram.exe Dec 31 '10 at 7:35 ...

Cross-references and garbage collection

Cross-references and garbage collection There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away. Would it be enough just to set to null the only referece which points to that subgraph to make it eligible for garbage collection? My concern is that internal cross-references may "protect" the entire subgraph from garbage collection. In other words, is the garbage collector wise enough to figure out that all references in a subgraph do not leave the boundaries of the subgraph and therefore entire subgraph can be purged. 3 Answers 3 As stated in this SO question, circular reference is well managed. Java does not do reference counting, ...

Java, Map same object to different objects

Java, Map same object to different objects I have a list of Car 's, I want to map them to different specific Car 's like - FordCar , HondaCar , VolkswagenCar ... base on value of maker attribute of Car , that is Car.maker Car Car FordCar HondaCar VolkswagenCar maker Car Car.maker Can Dozer, MapStruct do this? Or is there any framework in Java which can do this? Why Dozer? There is a standard Java type Map , see docs.oracle.com/javase/tutorial/collections/interfaces/map.html – Honza Zidek Jul 1 at 9:24 Map You can give MapStruct a try. mapstruct.org – Toan Lu Jul 1 at 9:25 @ToanLu thanks for your quick response, but here my problem is little different, for ex...

SQLiteException when querying a SELECT [on hold]

SQLiteException when querying a SELECT [on hold] I am developing an Android application with an SQLite database. It records transactions. The transactions table has the colums: transactions idTransaction INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT date DATE NOT NULL type INT NOT NULL details VARCHAR(100) NOT NULL notes VARCHAR(300) NOT NULL amount DOUBLE NOT NULL account INT NOT NULL category INT NOT NULL Also I made a method to get a cursor with all transactions: // Select all Transactions protected Cursor getTransactions() throws SQLException { Cursor mCursor = null; String colums = new String{"idTransaction", "date", "type", "details", "notes", "amount", "account", "category"}; mCursor = this.getReadableDatabase().query("Transactions", colums, null, null, null, null, "name ASC"); return mCursor; } In other class I made a method to move through the cursor that I get whe...

JAVA : Why do I get empty string from reading non-empty cell in xlsx file?

JAVA : Why do I get empty string from reading non-empty cell in xlsx file? I'm having trouble with reading an xlsx file. Basically, if I read it other than top to bottom, I get empty String from missed rows. For instance, if I read row 5 and then any row from 1 to 4, I get no answer whereas the cells are not empty and can be read if I do so before reading row 5. I use org.apache.poi.ss.usermodel.* Anyone having such trouble? Whats the code? The import alone doesnt help at all – XtremeBaumer 25 secs ago By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

I have some data in Firebase and want to retrieve it. Sometimes it can be null. How do I not get an exception for it?

I have some data in Firebase and want to retrieve it. Sometimes it can be null. How do I not get an exception for it? FetchDataMethod private void fetchData() { mDatabaseReference.child("UserData").child(RecieversId).addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { ImageView Image = (ImageView) findViewById(R.id.imageView); TextView Name = (TextView) findViewById(R.id.name); TextView Status = (TextView) findViewById(R.id.status); TextView Email = (TextView) findViewById(R.id.email); TextView Ph = (TextView) findViewById(R.id.ph); TextView Quote = (TextView) findViewById(R.id.quote); for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { String image = postSnapshot.child("Image").getValue().toString(); String name = postSnapshot.child("Name")....

How to install java through command prompt

Image
How to install java through command prompt I want to install java through command prompt command lines. Will it could be possible? your operating system..? – anoopknr Jul 1 at 9:00 Windows 7, Windows Server 2012 R2 – I_AM_Helpful_1 Jul 1 at 9:01 Related: stackoverflow.com/questions/28043588/… – David Conrad Jul 1 at 9:05 Well it is different for each java version I believe, but as I said in my answer, there is documentation about it on Oracle's website, here – Dan Jul 1 at 9:06 ...

| have added MySQL Connector to libraries , but still getting error 'java.lang.ClassNotFoundException: com.mysql.jdbc.driver' [duplicate]

| have added MySQL Connector to libraries , but still getting error 'java.lang.ClassNotFoundException: com.mysql.jdbc.driver' [duplicate] This question already has an answer here: import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet implementation class LoginChek */ @WebServlet("/LoginChek") public class LoginChek extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public LoginChek() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequ...

Java generics for optional single value or collection

Java generics for optional single value or collection I'm trying to define a container for a whole bunch of classes as some parts of the code will make more sense with a collection but other places will make sense with single values. Ideally I'd like to do this: public class AllModes<T> { private T<Car> car; private T<Boat> boat; private T<Train> train; private T<Plane> plane; ...40 more of these... } then I'd like to use the class like: AllModes<List> allModes; AllModes<Optional> oneOfEachMode; But I get the error I get is "The type T is not generic; it cannot be parameterized with arguments " The reason I'm defining these in multiple variables and not a single HashSet based on a superclass is I want to have get methods that return the correct types to avoid consumers of this class needing to cast down everywhere as each object has its own distinct fields. I also considered just storing a single value l...

Replacing busy loop and sleep in thread

Replacing busy loop and sleep in thread I have a Thread that calls a certain service. The service defines a callback function that can be called multiple times as long as there is data onProcessing(). The onCompletion() is called once it is finished. public CallThread implements Runnable{ public boolean isCompleted = false; public void run(){ ResponseObserver response = new ResponseObserver(){ public void onException(){ //Errors could happen sometimes so the program should just issue another request } public void onCompletion(){ isCompleted = true; //process the result } public void onProcessing(){ //This could be called multiple time } } //Service is the object that calls the service Service service = getService(); while(!isCompleted){ //Request object is populated Request req...

How == and equal works in java in Case of Integer Object? [duplicate]

How == and equal works in java in Case of Integer Object? [duplicate] This question already has an answer here: I have found many possible duplicates question on this but none clarifies my doubt on how it works? Integer a =25654; // a.hashCode()=>25654 Integer b =25654; // b.hashCode()=>25654 System.out.println(a.equals(b)); => true System.out.println(a == b); => false I have read this answer somewhere.. If no parent classes have provided an override, then it defaults to the method from the ultimate parent class, Object, and so you're left with the Object#equals(Object o) method. Per the Object API this is the same as ==; that is, it returns true if and only if both variables refer to the same object, if their references are one and the same. Thus you will be testing for object equality and not functional equality. in this case both object have same memory address(as per hashcode) still why does it returns false when we compare using == ? or the actual...

Can't get this Java program to work

Can't get this Java program to work Okay changed the code a bit, but the program still doesn't work properly. I want to be able to enter type of product (fruit) in the java console when program is run, enter any type of fruit (bananas, apples or oranges) and then enter a qty. import java.util.*; public class demo { public static void main(String args) { Scanner sc = new Scanner(System.in); String str = { "Bananas", "Apples", "Oranges" }; double price = { 2.09, 2.59, 2.25 }; int i = 0; int j = 0; System.out.print("Enter type of product: "); String string = sc.nextLine(); if ("fruit".equals(string)) { while (i < str.length) { while (j < price.length) { System.out.print(str[i++] + ": " + "£" + (price[j++]) + "p per bag n"); } } } System.out.print("n"); System.out.print("Enter which t...