java

Problem with resources location difference in eclipse and JARs

I wrote a program that is based completely on a single text file: I read the file, store the information, then search the information, etc. So, for the program to work, the file just has to be present and detectable by the program. I use eclipse, so I put the file is in the default resources map (src/main/resources). At the start of my p...

Difference between Java Collection and Collections

Hello, all! I just want to know what the actual difference between Java Collection and Collections is. Thanks in advance! ...

Java Recursion Problem

Hi, I have this bit of code to do some testing before I implement it. Basically on the second recursive call it should enter in on this line ( else if( sec >= 1 ) { return test( s ,lowerBounds + middle + 1, upperBounds ); } ) but it does not instead it goes on to the other else if and changes the value of sec. Am I missing something? pu...

run jar in eclipse

Hi! My problem is that I want to run some jar files in eclipse within a plugin. This jars make analysis on an eclipse project: String run_tool ="cmd.exe /C start java -Xmx400m -cp org-jcolumbus.jar;org-jcolumbus-schema.jar;lib/antlr.jar org.jcolumbus.tool.BuildModel -tasks "+src_dir+" -jsi "+SelProj.getLocation()+"/result/temp/"+SelPro...

How do I reliably access the HttpServletRequest in a jspx when it's behind a proxy?

I've got a jspx that needs to know the current HttpServletRequest's getServerName(). The jspx can fetch this with #{mybean.serverName} from its bean, like this: public String getServerName() { HttpServletRequest request = (HttpServletRequest) FacesInstance.getCurrentInstance().getExternalContent().getRequest(); return request.getS...

Which Swing component methods are thread safe?

According to Swing tutorial: Some Swing component methods are labelled "thread safe" in the API specification; these can be safely invoked from any thread. All other Swing component methods must be invoked from the event dispatch thread. Programs that ignore this rule may function correctly most of the time, but are subject to unpred...

Java: Comparing memory heap dumps in Netbeans

How do I compare memory heap dumps in Netbeans? What I have done is to configure my project to use profiling, then added several profiling points at chosen lines of code (similar to setting breakpoints). These profiling points trigger a "snapshot", which creates a memory dump. As my application is running, the profiling tab lists each ...

why it doesn't work correctly?

I have a table which in the first column ,I have student's name.such as "Esfandyar Talebi","Arash Nouri" and the number of rows can be changed. and just 2 rows are filled from 4 rows. the code that I have written: List<String> professorsName = new ArrayList<String>(); for(int i=0;i<InformationTable.getRowCount();i++){ ...

How can I get text from ComboBox?

I want to get the items of a combobox, and store it in an ArrayList object. ...

How to call a VB.NET application from a remote system by Java servlets?

I have an application in VB.NET. I want to call that application from a remote system by using Java servlets. Can anybody tell me the methods for that? ...

Initialize arrays using ternary operator

Hello guys, i tried something like this: boolean funkyBoolean = true; int array[] = funkyBoolean ? {1,2,3} : {4,5,6}; But this code won't even compile. Is there any explanation for this? isn't funkyBoolean ? {1,2,3} : {4,5,6} a valid expression? thank's in advance! ...

Running Junit & PowerMock with Mockito through PowerMockRunner from maven

Hi, I am not being able to run Powermock through maven. I'm the PowerMock Mockito and PowerMockRunner for driving a jUnit test. Here's the test: @RunWith(PowerMockRunner.class) @PrepareForTest( { UserLocalServiceUtil.class, ExpandoBridge.class }) public class AlertNotificationsTest { //... I haven't configured anyting special for ru...

Working with modules in IntelliJ IDEA

As I understand, using modules allows us to control some dependencies. I mean that we can allow one module to interact with another one but not vise versa. We also can make some reusable things and we can make deploying easier, if, for example, put all tests stuff into a separate module and won't deploy it to production. I haven't eve...

Java Swing: How to bind a JLabel's text to a column in the selected row of a JTable?

I am using Netbeans and am trying to find a way for the IDE to auto-generate the code for me. I remember binding a JLabel's text to a column in the selected row of the JTable before, but in that case, the JTable's values were from an entity manager, and it was very easy. I was wondering if there is a way to do it even if the JTable is no...

why this code about combobox doesn't work?

I have a combobox which stores "Computer ,Code:21","History ,Code:31" and also the number of items can be changed.but when I write this code for getting its items: List<String> bIHELessons = new ArrayList<String>(); for (int i=0;i<jComboBox1.getItemCount();i++) { String lessons = (String) jComboBox1.getItemAt(i); if (lessons != nu...

java - why do i keep getting -1 as the value of in.read(buf) ?

(To the Moderators ) please note that i had posted a related problem before but this is a more complete post so please dont close it as duplicate . you may close the previous post. whenever i get -1 in the console output no data is written in outputstream, whenever i get 3 in console output valid data is writtien in outputstream. the oc...

Screencast or video for Database programs in JAVA

Hello, Can someone point me towards a good video tutorial that teaches how to connect to a database (preferrably SQL Server) USING JAVA TO insert data? Thanks ...

Registering on long GC time events in Java

Is it possible to get a notification when a long GC cycle occurs? I'd like to write to our specific log when this happens. ...

How to select a line

So I'm trying to figure out how to implement a method of selecting lines or edges in a drawing area but my math is a bit lacking. This is what I got so far: A collection of lines, each line has two end points (one to start and one to end the line) The lines are drawn correctly on a canvas Mouse clicks events are received when clicking ...

draw dependency graph for a java class

Heyho, I'm searching for a tool like JDepend to draw a graph for a java classfile. JDepend seams to be fine, but it's not resolving the deps from the deps (maybe I'm just missing some special options?). A direct output into .dot format or an image would be nice to have. Thanks ...