Questions tagged [java]

465197 questions
1

votes
4

answer
1k

Views

Check if a Point is between two Points

I just recognized my math is a bit rusty.. I wanna check if Point C is between Point A and Point B. C can be on the line segment of A and B, or not. There can be three cases and I have to identify all of them: C is between A and B C / \ A---B C is in front of A and B C \ \ A--B C is in the b...
Steve Benett
1

votes
2

answer
5.3k

Views

Tracking mouse movement in java

I've been working on a basic tower defense game and was looking to track the movements of the mouse. I don't need it to track mouse movement when dragging but just when hovering over the screen so that the user can see where the tower is going to be placed. I've extended MouseAdapter to make a contr...
eatinasandwich
1

votes
1

answer
430

Views

Real-Time Excel Updates

I have a third party application that updates cell values by opening the excel file, setting values in cells, and writing (saving) the excel file. Suppose I have the excel spreadsheet open at all times, how I do have the spreadsheet reflect these changes in real-time? Every time there is an update,...
1

votes
1

answer
89

Views

Wrong colors in JLabel when using HTML string

I'm trying to use HTML styling in a JLabel and convert the BufferedImage to jpg. However the colors are quite different than what I expect. Here is the code: val html = "" + "teststring1" + key + " teststring" val textLabe = new JLabel(html) textLabe.setSize(textLabe.getPreferredSize) val d: Dimensi...
burak emre
1

votes
1

answer
240

Views

Java getting the auto-increment number of the current inserted row, to use it for another query?

public static void updateHistory(Client winner) { try { if (winner != null) { getDatabase().newQuery("INSERT INTO tournaments (`players`, `winner`, `winnerKills`, `map`, `prize`) VALUES ('" + tournyPlayers.size() +"', '" + winner.playerName + "', '" + winner.killCount + "', 'Wilderness', '" + winner...
Jony Kale
1

votes
3

answer
125

Views

outofmemory error using bitmaps Android

I've created an android app, which chooses a picture from Gallery and displays a preview. @Override public void onClick(View v) { if (v.getId()== R.id.button){ Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_PICK); startActivityForResult(Intent.createChooser(...
Frankenstein
1

votes
2

answer
958

Views

Is there any modern use for the bell character (\a)

I had the idea to make an INI reading/writing library for my personal use, so I looked up the specification on Wikipedia. In the Escape character section, I found one called the "Bell character". After some googling, I found this page that gave an example of how to use it. I tried it out, but I didn...
mattbdean
1

votes
1

answer
2.6k

Views

Unsupported FS format when integrating subversion with STS (eclipse)

The error below is being displayed when I attempt to import a project into SpringSource STS from SVN (Checkout Projects from SVN): Error validating location: "org.apache.subversion.javahl.ClientException: Couldn't open a repository svn: Unable to connect to a repository at URL 'file:///C:/var/svn/r...
Helen Reeves
1

votes
4

answer
214

Views

Runtime.exec(String) limiting String

I'm trying to use the Java function Runetime.exec(String) to run a program in the startup folder of a windows 7 computer like so: Runtime.getRuntime().exec(runner.getPath() + "\\run.bat"); And when I run this I get an error saying the command cannot be run: Exception in thread "main" java.io.IOExcep...
Shaun Wild
1

votes
3

answer
472

Views

Copy fileto SD Card from Raw folder after context-menu selection?

I'm (slowly) making an app which displays a list of tones and lets the user "long press" a certain one which then brings up a context menu asking if you'd like to copy it to SD card. Only problem is that last part, I need help. Basically the tones are stored in the Raw folder, and I need it that it...
Sean Burrage
1

votes
3

answer
17.8k

Views

how to return data to ajax from java Servlet [duplicate]

This question already has an answer here: How to use Servlets and Ajax? 7 answers i have my ajax function as follows: $.ajax({ type: 'GET', url: "/myservlet", data: { objects: '2', dimension: '2', }, success: function( data ) { console.log(data); alert(data); }, error:function(data,status,er) { ale...
roland luo
1

votes
1

answer
120

Views

Java and C# clients can not authenticate with a secured DataStax Enterprise 3.1 server

When enabling DSE specific authenticaton in DSE 3.1, Java clients and c# can not connect. Original Post: http://www.datastax.com/support-forums/topic/binary-protocol-with-internal-authentication-does-not-work-in-311-1
sdelmas
1

votes
1

answer
7.2k

Views

Spring - Use applicationContext from .jar file added as a dependency

Imagine a situation where there are 2 independent modules - Module A and B. Both of them are constructed using Spring. Each of them have its own applicationContext - Module A works with applicationContextA and B - applicationContextB. Module A contains facade class - defined in a bean moduleAFacade...
user1949763
1

votes
3

answer
5k

Views

Why methods mouseExited and mouseEntered run together when I enter or exit JDialog?

Yes, this question is already posted on JavaRanch but I do not understand them well. I have JDialog which has MouseListener added as follows: super.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { if (e.getSource() instanceof ConnectionTreeTooltip) { System.out...
Volodymyr Levytskyi
1

votes
3

answer
498

Views

Don't know what data structure to use for my algorithm

I'm trying to write my first algorithm and this is the pseudo code I am suppose to go off of. The algorithm is suppose to permute the set {0,1,2,3,4,5,6,7,8,9} for k spots. e.g n= set 0-9 so n=10 and r=k n^r permutations so U={0,1,2,3,4,5,6,7,8,9} (singly linked list) S is initially empty and let k=...
Steven
1

votes
1

answer
1.4k

Views

Using Derby EmbeddedDriver in Netbeans

I'm having troubl using Derby in a netbeans project on Windows. I've just downloaded and configured Derby and set the CLASSPATH variable to C:\Apache\db-derby-10.10.1.1-bin\lib\derby.jar;C:\Apache\db-derby-10.10.1.1-bin\lib\derbytools.jar; When I run the command java org.apache.derby.tools.sysinfo e...
Bugalugs Nash
1

votes
1

answer
55

Views

How to extract an Integral pattern out of a String using Regular Expressions

I am trying to make a mapLoader, which reads in a text file (here is an example) of the file [5,3,3,900,3,89,3,3,3,3,3,430,3,1439,3,65,3,320,3,3,3,3,3,3] [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21,3,3,3,3,3] [5,3,3,900,3,89,3,3,3,3,3,430,3,1439,3,65,3,320,3,3,3,3,3,3] [3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3...
Loligans
1

votes
5

answer
2.3k

Views

What minimum permissions/access rights does a SAP user need to be able to make RFC calls using JCo?

I'm trying to call a SAP function RFC_SYSTEM_INFO from Java application. I am using JCo 3.0 for that. I'm using the example code provided from JCo documenation. I get an exception Caused by: RfcException: [IA1|CZVBIIN101] message: No RFC authorization for function module DDIF_FIELDINFO_GET. Retur...
Ievgen
1

votes
4

answer
3.8k

Views

Android WebView getFavicon() returning null

I'm trying to get the favicon of the loaded page after using WebView webView = new WebView(getActivity()); webView.loadUrl("http://" + url); I'm attaching the asynchronous WebViewClient to the WebView to get the favicon after it loads webView.setWebViewClient(new WebViewClient() { @Override public v...
Jason Hu
1

votes
2

answer
103

Views

Add inputListener to texture

I have written a game in libgdx. Everything works fine, except one thing: When the player loses, a "Game Over" texture gets displayed to the screen. I'd like to add a "tap screen to restart" function to the game, but to do this, I need to attach an eventListener to the whole texture. Is this possibl...
PeterInvincible
1

votes
3

answer
2.6k

Views

Is it more efficient to read from an Excel file or an CSV file?

I need to write a quick program (using Java since its the only language I am really comfortable with) that takes an Excel file (or CSV) and parces through the data adding information that might be missing. The problem Im having is that I cant decide how to start, it feels like manipulating an Excel...
1

votes
1

answer
81

Views

Blackberry splash screen wait issue

I'm trying to launch a splash screen for a few seconds and then close it and launch the second screen. For some reason, the code executes the "sleep" before showing the splash page and the splash page appears only for a fraction of a second and the second screen appears immediately. In other words w...
Raza Ali
1

votes
2

answer
4.2k

Views

How to print multiple line input using PrintWriter to be saved on text file? Code inside

I have here a code which I will be using as a logging in my Java Server. This seems to be working fine in single line input. But when I entered multiple line. For example: Hey there! Hey More! And when I looked at the textfile which the PrintWriter had created, it show me: Hey there!Hey More! What...
Kerv
1

votes
1

answer
1.1k

Views

Unable to resize image and maintain transparency

The below code resizes an image. Unfortunately the image which is a vertical image has black bars on the sides. It looks as though the transparent, or blank space is being filled with black. I've tried setting the background color to white, and using alphaRGB but can't seem to shake it. OrderProd...
Webnet
1

votes
2

answer
205

Views

Add relativelayout programmatically

I have the following XML: As you can see above, there is a repeat of the same code (From ImageView to and this is just an example. I have to repeat it 41 times, instead of 3 that is shown here. Instead of using XML how do I add it programmatically (Let's say tvDate and tvReason are String arrays)?...
Si8
1

votes
3

answer
102

Views

beginner java - printing tables

I'm printing values from 0-99 and a random string from food array. I can't seem to output them to a table correctly. String foods[] = {"Bread", "Pizza", "Cheese"}; for (int x = 0; x
danieljohngomez
1

votes
2

answer
1.1k

Views

Java SocketChannel : Why wrap-flip-write doesn't work but wrap-write does?

Assume we have a Java SocketChannel connected to a server which is waiting for incoming data: SocketChannel server = SocketChannel.open(); server.connect(new InetSocketAddress(ip, port)); And we send our request as below: byte[] request = "This is a request for server!".getBytes(); ByteBuffer buffer...
Seyed Mohammad
1

votes
1

answer
1.4k

Views

Programmatically selecting/expanding a folder resource in Project Explorer

In Eclipse RCP, I'm programmatically creating a resource (folder with files) inside a Project, I wish to select and expand the folder (I know its path) in the Project Explorer (assuming it's opened). The effect should be similar than that of the "Link with Editor" button, but here the resource is no...
leonbloy
1

votes
1

answer
854

Views

WebView trigger a function in activity.java

So I have a web application that I am loading via WebView inside my android app. How can I call a function inside my android app when a user has clicked a button on the external website? Besides running that function I also want to be able to pass variables to it. Maybe link like myapp://activity/?d...
just some guy
1

votes
2

answer
5.2k

Views

java.net.MalformedURLException: Protocol not found: but file exists

hi i've this little method: private void modifyXML() { try { String filepath = main.fileWithPath; File f = new File(filepath); if(f.exists()){ System.out.println("Exists"); } DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docFactory.newDocumen...
David
1

votes
1

answer
926

Views

Clone an existing ApplicationContext in Spring

I have a multi-threaded application I am trying to write with Spring, right now I am using the new thread scope declaration on my beans and passing the same context into the Runnable class. The threading works fine and I get a new copy of the DAO/Services for each thread so exactly how I want it. Th...
Clarence Liu
1

votes
2

answer
4.5k

Views

can javafx media play mp4 format video files?

I am trying to play videos using javafx media. but I am unable to play video in local machine videos. I tried with default AdvancedMedia.java file javafx Ensemble.jar file. I copied same file code and pasted in my Eclipse. in that also playing few seconds and stooping. for few seconds. but instead o...
java think
1

votes
1

answer
4.1k

Views

Dealing with optional field in json

I have am trying to parse a json with following format JSONObject json; try { json = (JSONObject)parser.parse(value.toString()); String foo = (String) json.get("foo").toString();//error here String id1 = (String) json.get("_id"); JSONArray array = (JSONArray)json.get("bar"); } catch (ParseException...
Fraz
1

votes
2

answer
70

Views

How to make a plugin for Google Closure

I am currently using Closure/Plovr advanced mode to compile javascript. I want to add some custom functionality, such as string replacements and variable renaming. The important thing is that it requires parsed syntax. Is it possible to add this functionality? Is there an API for this or do I have...
ColBeseder
1

votes
2

answer
167

Views

Generic Types and Interfaces Java

Having these classes and interfaces.. public interface Shape; public interface Line extends Shape public interface ShapeCollection< Shape> public class MyClass implements ShapeCollection< Line> List< ShapeCollection< Shape>> shapeCollections = new LinkedList< ShapeCollection< Shape>>(); When I try t...
Diogo Ferreira
1

votes
1

answer
3.8k

Views

Tomcat 7 404 intelliJ resource not found

I have a simple tomcat server running from intelliJ and I'm trying to configure a servlet that will allow the user to select different colours of beer however I always receive a 404 resource not found once the form has been submitted. Is there a probjem with my code or is it a inteliJ config issue ?...
Chris Sewell
1

votes
2

answer
107

Views

Saving Objects from an Iterated List

I'm currently workin' on a sales module using java+hibernate+oracle... I'm done with my order form in my jsp like this: I'm getting my parameters doing this: ArrayList idMercaderias = new ArrayList(); ArrayList cantidades = new ArrayList(); ArrayList precios = new ArrayList(); for (int k = 0; k < 10...
Felipe Rodriguez
1

votes
1

answer
354

Views

OpenCL Java bindings for android

I am working in Java technology since 2010. So I am not use to C/C++ languages. Recently I need to use OpenCL for Java and android. There are many bindings of Java for OpenCL are available like JavaCL, oCL etc. JavaCL is based on JNA. Android does not support JNA. So is there any way to use these bi...
Adnan
1

votes
1

answer
667

Views

Reflections and multiple jars

I got two jar files, lets call them domain.jar and scanner.jar. In the scanner jar I have used Reflections library like so: Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(ClasspathHelper.forPackage(packageName)).setScanners(new SubTypesScanner(false))); Set
vertti
1

votes
1

answer
13.5k

Views

How do I switch to redirected url using selenium web driver

I would like to know if it is possible to switch to redirected url using java selenium web driver. I am doing automation for an app in facebook, but the developer of that app has used "Request dialog" facebook api feature which accepts "redirect_url" in java script. How do I switch my web driver to...
user2753523

View additional questions