Search Results

Search found 33640 results on 1346 pages for 'java generics'.

Page 165/1346 | < Previous Page | 161 162 163 164 165 166 167 168 169 170 171 172  | Next Page >

  • Java applet icon doesn't show

    - by user295744
    I have a java applet where I've changed the image icon that appears in the top left corner of the window. The code I use is this: Toolkit kit = Toolkit.getDefaultToolkit(); Image frameIcon = kit.getImage("src/myapp/resources/logo.png"); getFrame().setIconImage(frameIcon); Everything works fine until I deploy the applet to a standalone jar. In this case the icon that shows is the default icon, as if the code couldn't find the image. But the image is inside, although it is in the folder: myapp/resources/ What am I doing wrong here? Is this some weird java bug?

    Read the article

  • limit of connections with database and number of java threads in an application

    - by Jyoti
    Hi, I am working to develop a JMS application(stand alone multithreaded java application) which can receive 100 messages at a time , they need to be processed and database procedures need to be called for inserting/updating data. Procedures are very heavy as validations are also performed in them. Each procedure is taking about 30 to 50 seconds of time to execute and they are capable to run concurrently. My concern is to execute 100 procedures for all 100 messages and also send reply within time limit of 90 seconds by jms application. No application server to be used(requirement) and database is Teradata (RDBMS) I am using connection pool and thread pool in java code and testing code with 90 connections. Question is : (1) What should be the limit on number of connections with database at a time? (2) How many threads at a time are recommended? Thanks, Jyoti

    Read the article

  • Build Google App Engine Java source from Eclipse

    - by Robottinosino
    I would like to try to build Google App Engine for Java from source. I have tried this: I don't know how to solve the javac Ant task. I am on Mac OS X 10.6.8. The reason why I am trying to to create a Java Project from the source is that when I try to debug/step-into the sources downloaded from SVN, something is wrong in Eclipse and it does not track execution at the right code line. It seems to be executing "comment lines"? So I don't get an accurate tracking of the code path. I think what I would ideally need is: 1) svn checkout command with matching REV number of latest SDK 2) wget command downloading matching jar

    Read the article

  • The best alternative for String flyweight implementation in Java

    - by Dan
    My application is multithreaded with intensive String processing. We are experiencing excessive memory consumption and profiling has demonstrated that this is due to String data. I think that memory consumption would benefit greatly from using some kind of flyweight pattern implementation or even cache (I know for sure that Strings are often duplicated, although I don't have any hard data in that regard). I have looked at Java Constant Pool and String.intern, but it seems that it can provoke some PermGen problems. What would be the best alternative for implementing application-wide, multithreaded pool of Strings in java?

    Read the article

  • get entire line with java.util.scanner.hasNext(regex)

    - by Hussain
    I'm doing something in Java that requires input to be matched against the pattern ^[1-5]$. I should have a while loop looping through each line of input, checking it against the pattern, and outputting an error message if it does not. Sudo code: while (regex_match(/^[^1-5]$/,inputLine)) { print ("Please enter a number between 1 and 5! "); getNextInputLine(); } I can use java.util.Scanner.hasMatch("^[^1-5]$"), but that will only match a single token, not the entire line. Any idea on how to make hasMatch match against the entire line? (Setting the delimiter to "\n" or "\0" doesn't work.)

    Read the article

  • How to write web services in java

    - by gurupriyan.e
    Though this might appear as a duplicate of Java Web Services , I would like to know Where to start and to continue.In the past, I have invested so much of time to find where to start but I wasn't able to. There are so many jargons and chaos (at least for me!) while reading the pages about web services. There are so many terms - like JAX-RPC, JAX-WS, Axis, Rest, Servlet as WebService, EJB's as Web Service and other terms that I don't know. Can this User group consolidate and give a highlevel overview of Java Web Services which is easy to understand and follow? I appreciate your kindness and thanks for your help.

    Read the article

  • Setup sonar-runner for multiple java projects

    - by zetafish
    I am trying to run sonar-runner to analyze multiple Java projects in one go. According to the documentation http://docs.codehaus.org/display/SONAR/Analyse+with+a+simple+Java+Runner it is just a matter of creating a sonar-project.properties file for each project. But it is not clear to me where exactly I have to put these sonar-project.properties files. I tried to add multiple .properties files in the $SONAR_RUNNER_HOME/conf folder but the runner does not seem to pick them up. It only sees the sonar-project.properties file. Any suggestions on how to run sonar-runner for multiple projects?

    Read the article

  • Find java classes implementing an interface

    - by Linor
    Some time ago, I came across a piece of code, that used some piece of standard java functionality to locate the classes that implemented a given interface. I know the the functions were hidden in some non logical place, but they could be used for other classes as the package name implied. Back then I did not need it, so I forgot about it, but now I do, and I can't seem to find the functions again. Does anyone know where to find these functions? edit: I'm not looking for any IDE functions or anything, but rather something that can be executed within the java application.

    Read the article

  • Java Array Index Out of Bounds Exception

    - by user1302023
    I need help debugging the following program: I'm getting a run time error that reads: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at SearchEngine.main(SearchEngine.java:126) import java.util.*; import java.io.*; public class SearchEngine { public static int getNumberOfWords (File f) throws FileNotFoundException { int numWords = 0; Scanner scan = new Scanner(f); while (scan.hasNext()) { numWords++; scan.next(); } scan.close(); return numWords; } public static void readInWords (File input, String [] x) throws FileNotFoundException { Scanner scan = new Scanner(input); int i = 0; while (scan.hasNext() && i<x.length) { x[i] = scan.next(); i++; } scan.close(); } public static int getNumOfDistinctWords (File input, String [] x) throws FileNotFoundException { Scanner scan = new Scanner(input); int count = 0; int i = 1; while (scan.hasNext() && i<x.length) { if (!x[i].equals(x[i-1])) { count++; } i++; } scan.close(); return count; } public static void readInDistinctWords (String [] x, String [] y) { int i = 1; int k = 0; while (i<x.length) { if (!x[i].equals(x[i-1])) { y[k] = x[i]; k++; } i++; } } public static int getNumberOfLines (File input) throws FileNotFoundException { int numLines = 0; Scanner scan = new Scanner(input); while (scan.hasNextLine()) { numLines++; scan.nextLine(); } scan.close(); return numLines; } public static void readInLines (File input, String [] x) throws FileNotFoundException { Scanner scan = new Scanner(input); int i = 0; while (scan.hasNextLine() && i<x.length) { x[i] = scan.nextLine(); i++; } scan.close(); } public static void main(String [] args) { try { //gets file name System.out.println("Enter the name of the text file you wish to search"); Scanner kb = new Scanner(System.in); String fileName = kb.nextLine(); String TXT = ".txt"; if (!fileName.endsWith(TXT)) { fileName = fileName.concat(TXT); } File input = new File(fileName); //First part of creating index System.out.println("Creating vocabArray"); int NUM_WORDS = getNumberOfWords(input); //System.out.println(NUM_WORDS); String [] wordArray = new String[NUM_WORDS]; readInWords(input, wordArray); Arrays.sort(wordArray); int NUM_DISTINCT_WORDS = getNumOfDistinctWords(input, wordArray); String [] vocabArray = new String[NUM_DISTINCT_WORDS]; readInDistinctWords(wordArray, vocabArray); System.out.println("Finished creating vocabArray"); System.out.println("Creating concordanceArray"); int NUM_LINES = getNumberOfLines(input); String [] concordanceArray = new String[NUM_LINES]; readInLines(input, concordanceArray); System.out.println("Finished creating concordanceArray"); System.out.println("Creating invertedIndex"); int [][] invertedIndex = new int[NUM_DISTINCT_WORDS][10]; int [] wordCountArray = new int[NUM_DISTINCT_WORDS]; int lineNum = 0; while (lineNum<concordanceArray.length) { Scanner scan = new Scanner(concordanceArray[lineNum]); while (scan.hasNext()) { int wordPos = Arrays.binarySearch(vocabArray, scan.next()); wordCountArray[wordPos]+=1; for(int i = 0; i < invertedIndex.length; i++) { for(int j = 0; j < invertedIndex[i].length; j++) { if (invertedIndex[i][j] == 0) { invertedIndex[i][j] = lineNum; break; } } } } lineNum++; } System.out.println("Finished creating invertedIndex"); } catch (FileNotFoundException exception) { System.out.println("File Not Found"); } } //main } //class

    Read the article

  • How to create initializeDB() method for java database

    - by Holly
    I am working on a Java project for class and have not worked much with incorporating databases into Java. I can't find much on the initializeDB() method, but if I could get some help I would really appreciate it. Below is the code being used for the intializeDB() method: private void initializeDB() { try { // Load the JDBC driver System.out.println("Driver loaded"); // Establish a connection System.out.println("Database connected"); // Create a statement // Create a SQL Query string // Execute the query to create a recordset } catch (Exception ex) { ex.printStackTrace(); } }

    Read the article

  • How does java LoginContext.login() work?

    - by tangens
    I have this code to create a configuration of a java client to connect to a JBoss application server: System.setProperty( "java.security.auth.login.config", "auth.conf" ); LoginContext auth = new LoginContext( "myAuth", new LoginCallbackHandler( username, password ) ); auth.login(); The file auth.conf contains the following lines: myAuth { org.jboss.security.ClientLoginModule required; }; Now, somewhere else in the code (the LoginContext auth isn't known there) I have an EJB that does a initialContext.lookup( jndiName ) and a narrow() to access a Bean on the JBoss application server. This narrow only succeeds if the login information of the first step was correct. Question How does the login information propagate from the LoginContext to the narrow()? I don't see any connection between these two places. And further, how could I do two or more different logins inside of one client?

    Read the article

  • Is there a writable iterator in Java?

    - by Lukasz Lew
    In C+ one can use iterators for writing to a sequence. Simplest example would be: vector<int> v; for (vector<int>::iterator it = v.begin(); it!=v.end(); ++it) { *it = 42; } I need something more complicated - keep iterator as a class member for a later use. But I don't know how to get this behavior from Java iterators. Are there writable iterators in Java at all? If not then what replaces them?

    Read the article

  • Deploy java (command line) app using Netbeans / ant

    - by Haes
    I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment: Do you check in all the Netbeans project files into the repository, normally? If I build the project using Netbeans (or ant) I get a .jar file and some additional jar libraries. In order for the app to run properly on the server, some additional config files and directories (log/ for example) are needed. The application itself is a J2SE application (no frameworks) which runs from the command line on a Linux platform. How would you deploy and install such an application? It would also be nice if I could see what version of app is currently installed (maybe by appending the version number to the installed app path). Thanks for any tips.

    Read the article

  • mac, java 1.5: javax.mail not recognized as a jar file

    - by Helpme
    hello fellow java developers, Having a little issue with creating a java application on a macintosh computer (snow leopard). I've set up my application in eclipse, added all of the appropriate jar files, but for some reason the code is not recognizing some of my variables as valid types. I've imported the libraries via import javax.mail.*; import javax.mail.internet.*; These libraries are not recognized by the application. BUT I've put them on the build path! Any advice on how to fix this?

    Read the article

  • Strange behavior of Switch Case statement in Java

    - by supernova
    I understand that Java switch case are designed this way but why is this behavior in Java int x = 1; switch(x){ case 1: System.out.println(1); case 2: System.out.println(2); case 3: System.out.println(3); default: System.out.println("default"); } output : 1 2 3 default My question is why case 2 and 3 are executed? I know I omitted break statement but x was never 2 or 3 but case 2 and case 3 still executes?

    Read the article

< Previous Page | 161 162 163 164 165 166 167 168 169 170 171 172  | Next Page >