Skip to main content

Posts

Showing posts from February 10, 2012

JSON PHP data returning null

i am trying to fetch a PHP script using AJAX and return the values as JSON. For some reason, my script fails and i am trying to figure out the problem. When i enter a value form the database into the address bar, like www.someaddress/post.php?kinaseEntry=aValue i get a json out put like so; {"kinaseSKU":null,"url":null,"molecularWeight":null,"tracerSKU":null,"antiSKU1":"antiSKU1","antiSKU2":"antiSKU2","bufferSKU":"bufferSKU","tracerConc":null,"assayConc":null} My php file looks like so; <?php //Include connection to databse require_once 'connect.php'; $kinase = mysql_real_escape_string ($_POST["kinaseEntry"]); mysql_query('SET CHARACTER SET utf8'); $findKinase = "SELECT * FROM kbaData where cleanSKU = '" .$kinase. "' "; if ($result = mysql_query($findKinase)) { $row = mysql_fetch_arra

How can I add a variable to an array?

How can I add a variable to an array? Let say I have variable named $new_values : $new_values=",543,432,888" And now I would like to add $new_values to function. I tried in that way: phpfunction1(array(114,763 .$new_values. ), $test); but I got an error Parse error: syntax error, unexpected T_VARIABLE, expecting ')' How my code should look if I would like to have array(114,763,543,432,888) ?

get function name that called function without arguments

I have a class admin_model with the private method admin_form() There are a number of other public functions that call this method. Is there a way to get the name of the function that called admin_form() from INSIDE admin_form() ? I could easily add an argument when calling admin_form() like: $this -> admin_form(__FUNCTION__); then inside admin_form($caller) I have the caller. It will be $caller But i was hoping there was a way to do this WITHOUT passing arguments. Any Ideas?? Cheers, Alex

mail() function in PHP does not works in local system

I am using php mail(). I have been working in my local system, I mean not a domain. is shows php error as bellow Error Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() I tried this http://pastebin.com/SNcnPi5c to check but does not works fine what i need to change?

flash object not displaying in firefox

When i first load the page the flash container div is set to display:none, i then apply some jQuery to .fadeIn() and set the div heigth and width size. Fine. But within this div i embed the flash object this way: <object width="692" height="389"> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="wmode" value="transparent"> <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php the_field('vimeo'); ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /> <embed src="http://vimeo.com/moogaloop.swf?clip_id=<?php the_field('vimeo'); ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_

Converting MySQL to PDO

I've been advised a couple of times on here to start changing my code to PDO and I've finally got round to doing it. My problem is that I'm having incredible difficulty with converting my existing login script. For the last few lines of the code below (after the line $result = $query->fetchAll(); ) I haven't been able to find any resources online that could help me re-write it: $username = $_POST['username']; $password = $_POST['password']; $db=getConnection(); $username = mysql_real_escape_string($username); $query = $db->prepare( "SELECT password, salt, 'employer' as user_type FROM JB_Employer WHERE Username = '$username' UNION SELECT password, salt, 'jobseeker' as user_type FROM JB_Jobseeker WHERE User_Name = '$username'"); $result = $query->fetchAll(); $qData = mysql_fetch_array($result, MYSQL_ASSOC); $hash = hash('sha256', $qData['salt'] . hash('sha256', $password) ); if (

INNER JOIN not working properly

I have a problem with a mysql join i'm trying to complete. This is my code: SELECT title, books.`author_id`, books.`publisher_id`, books.`format_id`, books.`genre_id`, pages, isbn, description, DATE_FORMAT(release_date, '%M, %d, %Y') FROM `books` INNER JOIN `authors` ON (`authors`.`author_id`= `books`.`author_id`) INNER JOIN `publishers` ON (`publishers`.`publisher_id`= `books`.`publisher_id`) INNER JOIN `formats` ON (`formats`.`format_id`= `books`.`format_id`) INNER JOIN `genres` ON (`genres`.`genre_id`= `books`.`genre_id`)` authors, publishers, formats and genres are all separate tables each with two columns. author_id and author in the case of the authors table, and the same format for the others. The join doesn't seem to work no matter what i do, please help me to see where i've gone wrong.

Jquery table onclick events

I have A function in jquery which goes to a php file, which querys a database returns the results in a table with a button in each row, how do i access the buttons in the page that the jquery is on. here is some code //function to get table form php file with button on each row function show(str) { $.post('INCLUDES/gettable.php',{club: str}, function(output) { $('#box').html(output).show(); }); } //when button from table is clicked do something $("button").click(function() { alert("hello"); } Any help is appreciated

Some Image Editing examples needed [closed]

I am looking for some code which manipulates images of arbitrary facial images. It should recognize the locations of the left and right eye, mouth, and cheeks to apply the effects properly. If possible editing the image such that it looks like "damage" is done to the face each time the application is run on the image. example: -Give black eye to left eye -Give black eye to right eye -Bloody mouth/lip -Bruises on cheek/face Each effect should be singular, and additional effects are added when the application is run again on the image. The application needs to run on linux and can be command line. I will be implementing the application using a php script. I know there are plenty of guys out there already done these kind of projects, so please help me out. Thanks in advance...

Shopify API - add to basket

I'm thinking of using Shopify to manage my shop. I need to add the products to the website with the API. http://api.shopify.com/ I can get the products and stocks with this API call : http://api.shopify.com/product.html#index But, then I would like to 'Add to basket' - I cannot see from the API docs how to do this. Once added to the basket - I'd like to get the basket contents so I can display something like... "2 items : £130 - checkout" I don't need a detailed answer - just point me in the right direction - thanks.

How to spot all $tickers in string?

Consider the following string: $MRK - Merck - ($AAPL, $MSFT, $F) having day $AA! like $P and me :) Although it's jibberish, it shows my problem. I want to scan for all words starting with a dollar-sign ($) and check them against a pre-defined list of tickers. If there's a match, replace them with a label ({TICKER}), as follows: {TICKER} - Merck - ({TICKER}, {TICKER},{TICKER}) having a day {TICKER}! like {TICKER} an me :) I now use this function: function _process_tickers($string) { $result = db_query("SELECT symbol FROM us_stocks"); while ($row = db_fetch_object($result)) { $tickers[] = ' $' . $row->symbol . ' '; } return str_replace($tickers, ' {TICKER} ', $tweet); } Problem: this only catches tickers that are surrounded by spaces (this $AA is surrounded by spaces) but not other situations like (this ticker has only a space in in front $AA) or (this one is surrounded by commas: my,$AA, ticker). But also two tickers right

Does using method chaining in PHP cause any problems with resources or memory?

I'm talking about methods like this: $object->method()->method1('param')->method2('param'); Those are created by returning the object in the function. return $this; I've seen third-party software use that method, but I'm wondering, wouldn't that cause a bit of a problem with the resources or memory because you're continuously returning the entire object?

PostGIS function to connect geometry LINE together?

(note: the_geom is a geometry value (TYPE: LINESTRING), in this case i random them for readability) gid | kstart | kend | ctrl_sec_no | the_geom | the_sum_geom 626 | 238 | 239 | 120802 | 123456 | NULL 638 | 249 | 250 | 120802 | 234567 | NULL 4037| 239 | 249 | 120802 | 345678 | NULL [Real Practice Description] just skip this for those who don't mind the purpose I would like to do 'this' (a set of queries from my past question, link located on the end of this post) for every row in Table B (aka. land_inventory). These two tables are related by 'ctrl_sec_no' (aka. control section number of a road) which means :: in ONE ctrl_sec_no -- 120802 (in fact, it is a road which is equivalent to 3 geometry LINESTRINGs (the_geom) connected together, from kstart 238 (start at kilometre of 238) to kend 250) [PostGIS question] the question is how to connect this 3 lines {aka gid(626,638,4037) from the table} together a

Database error after moving website?

I just moved my website from a test domain to the actual domain and I changed the DB info in the PHP script, but I'm still getting an error even though I triple-checked that I have the correct database, host, username and password. Am I missing something? This is the code I use to connect. The database info is definitely correct. $dbhost = "localhost"; $dbuser = "username"; $dbpass = "password"; function dbConnect($db='dbname') { global $dbhost, $dbuser, $dbpass; $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) or die('Database problem.'); if ($db!='' and !@mysql_select_db($db)) die('Database not available at the moment. Please try again in a couple of minutes.'); return $dbcnx; } And then I call the function dbConnect('dbname') from the script. The error I get is the second error from the code above, "Database not available at the moment. Please try again in a couple o

Jboss 7 auto deploy plugin cannot connect to localhost:8080

I configured the plugin in maven as shown below <plugin> <groupId>org.jboss.as.plugins</groupId> <artifactId>jboss-as-maven-plugin</artifactId> <version>7.0.2.Final</version> <configuration> <hostname>localhost</hostname> <port>8080</port> <filename>target/TestApp.war</filename> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin> I then trigger it using maven using mvn -U clean install package It does build and everything works fine bu

Can"t read Arabic text file in Java

i am trying to read arabic text using Java , yet the scanner does not see any elements and thus reading is unsuccessful although LineNumberReader recognizes lines in the text file. i have tried the same code on English text and it works fine. i am using netbeans 7.0.1 here is my code : public class ReadFile { private int number_of_words; private File f1; private String array[][],lines[]; private Scanner scan1; public ReadFile(String sf1) throws FileNotFoundException { f1=new File(sf1); scan1=new Scanner(f1); } public String[][] getA() { return array; } public void read() throws IOException { int counter=0,i=0; LineNumberReader lnr = new LineNumberReader(new FileReader(f1)); lnr.skip(Long.MAX_VALUE); number_of_words=lnr.getLineNumber(); array = new String[2][number_of_words]; lines = new String[number_of_words]; while(scan1.hasNext()) { S

killProcess blocked by DefaultHttpClient.execute

I'm writing an application which at the beginning connects with the server and waits for its response. To achieve this I'm using DefaultHttpClient.execute method with response time set to default. This execution is triggered as a separate thread which is set as daemon. Still, when I try to kill an application through android.os.Process.killProcess call there is a significant lag, which I'm guessing is related with DefaultHttpClient.execute mechanism (not-daemon thread execution?). Is there a way to kill my connection just after killProcess call?

Using OO PHP in CSS

tl;dr - I'd like to know if it is possible to pass an object into a PHP file with CSS headers, such that I can use this object to manipulate various CSS attributes. What I'm attempting to do, is allow my PHP/CSS file to interact with the other objects/php files in the webpage, e.g. menu item objects. My ultimate goal is to use PHP in the CSS file to count the number of menu items, and apply the appropriate width value in order to space them out evenly on the page. I use a very simple color based example below to demonstrate my understanding so far... I understand that for basic usage of PHP in a CSS file, one can do something like: <?php header("Content-type: text/css"); $dkgreen = '#008400'; body { background:<?=$white?>; } ?> I also understand that OO PHP can be used to achieve a similar thing, e.g.: class css { function __construct($args=array()) { foreach($args as $key => $field) { $this->{"$key&qu

Registration blanket, database, info, wordpress, mySQL, e-mail

I'm making websites for a company where users have to "register" with names and a lot of different information to attend the event. (It's a video-event - info would be name, e-mail etc.) I now got a Wordpress webpage, at the blanket doesn't necessary need to be on the site, but can open in a separate window. I need to, somehow make it easy for admin to look at the users who registered, send them e-mails etc. Make a list of everyone who register, for the admin to see. How would be the easiest way to do this? I know how to make a form, and pull the information into the database.. Any good ideas, plugins or examples?? Thanks

Behaviour of glob function in php is different with open_basedir

I migrate from sugar 5.2 to sugar crm 6.2 and i'm using open_basedir and it doesn't work ... I detected the problem in the code. It's the function glob which returns false (with open_basedir) instead of an blank array (with open basedir disactivated) The file with the problem is modules/ModuleBuilder/parsers/views/History.php line 72. foreach (glob($this->getFileByTimestamp('*')) as $filename) { if(preg_match('/(\d+)$/', $filename, $match)) { $this->_list [] = $match[1]; } } (if glob return null, there is an error) When I look for the documentation of glob http://fr2.php.net/glob , there is a flag *GLOB_ERR* : Stop on read errors (like unreadable directories), by default errors are ignored. But it doesn't change, the result is false and I've no error. The configuration of open base dir allow the application path, /tmp and /usr/share Does someone know how to resolve that

registered user area package

I want to create a new service which needs a registered user area. I need to customize the fields and look of this rua. I am writing cause I don't want to reinvent the wheel. Is there an opensource php script I can use in a project that simply handles the security issues which I can access with something like: if ($registered) { // things }

Shared library for two projects

I'm running two webapps (based on Spring, JPA and JSF) on the same tomcat server. Now my WARs beginning to get big in size which I would like to change. For development I'm using the embedded jetty/tomcat plugin - maybe this is interesting. What I want to achieve is: Creating a jar which holds the classes which are needed for both projects, e.g. Spring, Hibernate and MySQL - I want to build those as a seperate JAR and deploy this on the server. My next thought was to provide this bundle to my projects as dependency with provided scope. That would shrink my WAR files. Can I achieve this on a really simple way? It would be great if I could use the embedded jetty/tomcat server for development.

How to use getSystemCpuLoad() in JMX

Hi i cant able to use getProcessCpuTime() or getProcessCpuLoad() or getSystemCpuLoad() in my java program. I used like below. ManagementFactory. getOperatingSystemMXBean().getProcessCpuTime(); also like this ( (OperatingSystemMXBean) getOperatingSystemMXBean() ).getProcessCpuTime() But its showing error like method getProcessCpuTime() is not found. I included the following header files. Is that enough or i need to use any more.? import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; Can anyone please suggest me how to use these methods. am using jdk1.6. And my code is below import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; import java.lang.reflect.Method; import java.lang.reflect.Modifier; public class printUsage { public static void main(String[] args) { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); System.out.println("getCpuProcessTime(

Java code to find a particular number from a given list of numbers

How would you solve the following java problem? Write code that finds a particular number from a given list of numbers which are stored as strings? I assume you would have to convert the strings to ints or doubles, using double.parse double or int.parse int and then do some kind of binary search maybe? Here's what I have tried so far import java.io.*; import java.util.Scanner; public class FindNum { static int nElems; static String[] array; public static void main (String[] args) throws IOException { File testFile = new File("X:\\numbers.txt"); Scanner in = new Scanner(System.in); System.out.println("What number would you like to find?"); nElems = in.nextInt(); while(true){ System.out.println("Binary search"); array = new String[nElems]; getContents(testFile);//loads the file That's just basic input to get the access the file witht the list of numbers wondering how would I go about coding a binary se

Swing high-performance charting library

I'm currently looking for a Swing component that will allow me to draw about 5000 points per sequence for at least 3 sequences with an update frequency greater or equal to 100 Hz (and preferably pretty looks). A clean API is definitely a plus and another plus is the possibility of having two (or more) vertical axes. The targets are java 6 and 7. Solutions which are not 100% java should support at least Windows 7 and Mac OS X Lion. Commercial and F/OSS solutions equally welcome. Thanks in advance

JCharset not being recognized in browser

I am working on a simple email client using a Java applet. I am getting the exception "java.io.UnsupportedEncodingException: utf-7" when I open certain emails. I have added JCharset, and that fixes the issue when I run the applet in NetBeans' applet viewer, but when I run it in a browser I get the same exception. I have added the necessary file "java.nio.charset.spi.CharsetProvider" to META-INF/services, which is in my src directory. What else do I need to do to get it to recognize it when I run it in the browser?

Exception while trying to use jersey and jaxb

The following code: @POST @Path("/previous-status/{current}") @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.TEXT_PLAIN) public String getPreviousStepStatus(@PathParam("current") JAXBElement<WorkflowStep> step) { WorkflowStep wfStep = step.getValue(); return DBAccessor.getPrevStepStatus(wfStep); } Produces the following exception: javax.servlet.ServletException: Servlet.init() for servlet Jersey Rest Service threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) org.apach

How to extract textual contents from a web page?

I'm developing an application in java which can take textual information from different web pages and will summarize it into one page.For example,suppose I have a news on different web pages like Hindu,Times of India,Statesman,etc.Now my application is supposed to extract important points from each one of these pages and will put them together as a single news.The application is based on concepts of web content mining.As a beginner to this field,I can't understand where to start off.I have gone through research papers which explains noise removal as first step in buiding this application. So,if I'm given a news web page the very first step is to extract main news from the page excluding hyperlinks,advertisements,useless images,etc. My question is how can I do this ? Please give me some good tutorials which explains the implementation of such kind of application using web content mining.Or at least give me some hint how to accomplish it ?

How can I get started writing code? [closed]

I am currently learning Java in college. I have noticed a problem I have when I am starting to code to solve problem. The problem is that I don't know exactly how to start. For instance, if I try to think about the question and a way of coding the solution then I always say to my self "what about this case.. and this case..." and don't know where to start. So my question for people with experience in programming, is how do you start? Do you think about a solution for all the cases first, then start to write the code? Or maybe first you try to write the steps in your own language and then go and write the code? Or maybe you go ahead from the start, start typing some code and at the same time think about all the options and fixing and changing what you wrote?

EJB - GWT. Notificate GWT(javaScript) client about some events happened

I want to make document printing service using GWT(javascript+servlet) and EJB. What is the best way to cause EJB to notificate GWT client about some event is happened? Of course, I can make it with using Timer (send request to EJB with some interval), but may be exist some more elegant way? (for example with callback, but I dont understand how to release it). P.S.: I will use multitier architectur: JavaScript(GWT)+Servlet(GWT RPC)+EJB. And i working on document printing service (i want to notificate client that some file(s) is printed (also will be good if you give me advice of making progress bar)). Thanks!

java: concurrent collections

I'm trying to find one or more concurrent collections to use that I can implement the following behavior (the names are contrived for analogy purposes): /** * Acts as a broker for a concurrent hash map that stores its keys in order * of submission. At shipping time, the concurrent map is "sealed" * (picture a truck with its cargo door being closed) * and its contents presented as an immutable map, and is replaced * by a new concurrent map ready to accept values. * * Consumers of this class that submit information to it, are expected to * know that this contains a concurrent collection, and should use the * compareAndSet paradigm, e.g. the following: * * LoadingDock loadingDock = ... * boolean done = false; * while (!done) * { * V oldValue = loadingDock.get(); * V newValue = computeNewValue(oldValue, otherInformation); * if (oldValue == null) * done = loadingDock.putIfAbsent(newValue) == null; * else * done = loadingDock.replac

Hit test on Graphics2D object?

I have a few Graphics2D objects (Line2D, Rectangle2D, Ellipse2D, Rectangle2D) and a GeneralPath. I know that if I want to hit test on them I could use the .contains(Point) method, but I need to hit test on these objects when they are not filled in. So I just want to test if the user clicked on their border/line. I don't need to worry about the thickness of the border for now. Let's say that I just need to worry if the user clicked within 10 pixels from the border/line. I do have a MouseListener where I can get the coordinates of the mouse click, and my Graphics2D objects are stored on a data structure that I iterate over. I just don't know how to hit test on the lines/borders. Any suggestions will be appreciated!

Java MyBatis stored procedure call with OUT parameters

First question: I am trying to return one OUT parameter and not a result set with annotations. First, is it even possible? If it is, how would one do this? MyBatis: 3.0.6 Database: SQL Server 2008 Here is an example of the syntax of my method call in the UserDAO: @Select(value= "{ CALL saveUser( " + "#{userId, mode=IN, jdbcType=INTEGER}," + "#{firstname, mode=IN, jdbcType=VARCHAR}," + "#{lastname, mode=IN, jdbcType=VARCHAR}," + "#{message, mode=OUT, jdbcType=VARCHAR}" + ")}") @Options(statementType=StatementType.CALLABLE) public String saveUser( @Param("userId") int userId, @Param("firstname") String firstname, @Param("lastname") String lastname); I am returning a message from all of my "save" procedures and so I can return a response to the user: "User save successfully","Error saving user",&q

trying to get the calculator to return 0 not an error message when a number is divided by 0?

Here is problem in a nut shell. I have made a basic caluclator in java but I am trying to getting the calculator to return 0 when a number is entered and it is divided by 0. Each time I keep getting an error message! class Calculator { long sum; public void evaluate( char action, long number ) { if (action == '+') { sum = number + number; } if (action == '-') { sum = number - number; } if (action == '*') { sum = number * number; } if (action == '/') { sum = number / number; } **if (sum == number / 0) { sum = 0; } }**

Java Android Eclipse AVD "Unfortunately, <project name> has stopped.&rdquo;

In the eclipse/android AVD, I get "Unfortunately, has stopped" I have checked other Qs about this, but none helped. I assume it is my code that is faulty, because when I comment the code out, it runs fine. However, the android code-checker thingy shows no errors. This is my code: public TextView TextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setTextView(); } public void setTextView(){ TextView tv = (TextView); findViewById(R.id.textView1); tv.setText("4"); } I tried this aswell, but the same happened public TextView TextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView); findViewById(R.id.textView1); tv.setText("4"); } I'm not sure whether the structure of my code is correct either.

Using two private keys (keystore) and two public keys (truststore) in one SSL Socket Connection

I need to use to key-pair in one socket ssl connection without change nothing in clients. Why? Because one client use a CN attribute in trust store for connection handshake and other clients using another value in the same attribute to process the same task in the same way. So I need to use two key store (private) with distinct CN attributes and also aliases and share two different trust store (public key) with distinct CN attributes and also aliases too. Describing bellow: keyStore1 Keystore type: JKS Keystore provider: SUN ... Alias name: identity1 ... Owner: CN=app1, OU=..., ... Issuer: CN=app1, OU=..., ... ... keyStore2 ... Alias name: identity2 ... Owner: CN=app2, OU=..., ... Issuer: CN=app2, OU=..., ... trustStore1 ... Alias name: identity1 ... Owner: CN=app1, OU=..., ... Issuer: CN=app1, OU=..., ... ... trustStore2 ... Alias name: identity2 ... Owner: CN=app2, OU=..., ... Issuer: CN=app2, OU=..., ... I tried to implement this feature in this way: KeyStore Key

Java deploy webservice ejb to Windows Weblogic

i have a problem with deploying webservice jar file to Weblogic. If i deploy on same version WL linux machine works ok. If i deploy to windows machine it gives error msg NoClassDefFound. It cant find class i defined in webservices.xml file under handler-chain tags. its like com.something.SoapBodyHandler. On linux, handler is working. If i deploy to windows without that tag it works. Its like it couldn't find com/something/SoapBodyHandler

Convert file located in OSGi Bundle to IFile

I have an installed bundle (org.osgi.framework.Bundle) in my running eclipse. There is a file in this bundle. I have the path to the file and i can represent this file by an URL (java.net.URL) by using URL url = bundle.getEntry("/folder/file") . Is there a way to get a handle of this file of type IFile (org.eclipse.core.resources.IFile)? I need a reference of the file located in the installed osgi bundle of type IFile. But I don't want to copy the file temporary on my local disk (like workspace). Thanks in advance!

print out hashmap collision

Is there anyway I can print out the Keys with the values that had collisions ? If a key has two values I want to be able to print out those values how can I do that I am inside the hash map class and making modification to it.

Using xsltproc style sheet in java

I would like to convert an xml to a text with java. Until now i have used xsltproc with a style sheet file. Now i would like to do this inside a java class, and i would be very happy if i can do this reusing the style sheet of xsltproc. Is there any way to do this?

How to set Default opening window in Swing?

I have an application that has two different login windows for two different types of users of application, say one is client and the other is administrator , now i want to have an option on both the Login windows to set the default opening window, something like a checkbox having label as set this is as your default Login window .. How can i achieve this?? May i use a .properties file to set the default window? (and How?) Or, a Main.java class which loads first and decides the default GUI window to load first?? I preferred the 2nd way...but your views are welcomed, also please provide some example codes to accomplish this task.

Is there a way to block a class from being reflected upon?

I am making a cipher class while teaching myself about java's security api. This class is going to have some sensitive stuff in it, such as the type of encryption and the like. All of this can be reflectively retrieved it some one had the motivation. I have used reflection to bypass private variables and methods before (not proud of it), so I know that can be done. Is there a way to wholly prevent reflection from working on an entire class - or even parts of it, or does that go against java's - more specifically the security api - design?

How to index file names (and other file metadata) in nutch?

It seems like nutch indexes only (some) parse results. It runs the indexing filters which detremine what is indexed. These indexing filters get a Parse result as a parameter. How can I achieve file names and other file metadata like owner being indexed? Of course I need to add an indexing filter, but to do I also have to add a parser for parsing all filetypes and getting their metadata?

Find duplicates in large file - java

I have really large file with approximately 15 million entries. Each line in the file contains a single string (call it key). I need to find the duplicate entries in the file using java. I tried to use a hashmap and detect duplicate entries. Apparently that approach is throwing me a "java.lang.OutOfMemoryError: Java heap space" error. How can I solve this problem? I think I could increase the heap space and try it, but I wanted to know if there are better efficient solutions without having to tweak the heap space.

JNI how get values updated to int and double fields

How do two values I pass into my JNI tossed down to C then C does its changes and updates the values. How do I get those two values(maxPower, index) and see then in Java? They always come back as zero. JNIEXPORT jdouble JNICALL Java_com_TV ( JNIEnv* env, jobject obj, jdouble maxPower, jint index) { jdouble result = 0; result = Feature_TV(2, &maxPower, &index ); return result; } // here is the c function it calls it actually does more than this but for // demo it should return result 60 and maxPower and index should be -5.0 and -2.. double Feature_TV(double * maxPwr, int * maxPwrIdx ) { *maxPwr = -5.0; *maxPwrIdx = -2; /// do something return 60; }