stephen84s 550 Nearly a Posting Virtuoso Featured Poster

m doing project on tracking keyboard,mouse & URL activity.
which programming language is much easier to implement this project? Is Java better
or VC++ is more better option?

Seems like an academic project, so normally the language you know best is the easiest option.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
#include "Helloworld.h"

	JNIEXPORT void JNICALL Java_helloworld_hello (JNIEnv *, jobject) {
		printf("Hello world!\n");
		return;
	}

Now I am curious, how did that compile, if I haven't completely forgotten my C++, shouldn't there be a name given to the parameters of the function in the definition like this:-

JNIEXPORT void JNICALL Java_helloworld_hello (JNIEnv *env, jobject obj) {

BTW another question, where are you loading the DLL ? Before using the "native" method (in your java code) you need to load the library, by using either the System.load(String dllFile) or System.loadLibrary(String libName) methods.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

But now when I try to use this command:
Cl/LD NativeDemo.c
the response I get is:
'Cl' is not recognized as an internal or external command,
operable program or batch file.

That my friend is because you have not installed the C compiler needed to compile your .C file. The function of the above command (Cl/LD) is I suppose to generate a DLL from your C/C++ file, and it corresponds to invoking the C compiler (which the tutorial you are using refers to) just like the javac command invokes the java compiler.
As far as which compiler your tutorial is using ... I dont know, just like NormR1 said google it.

How should I proceed after this, and where exactly can I link my .c file with me Java code?

You cannot link with the source code file, you need to get either a DLL or a *.so file from your .C file to link it with your Java code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The API says:-

BlockingQueue implementations are thread-safe. All queuing methods achieve their effects atomically using internal locks or other forms of concurrency control. However, the bulk Collection operations addAll, containsAll, retainAll and removeAll are not necessarily performed atomically unless specified otherwise in an implementation

It says specifically "bulk Collection operations .... are not thread safe unless specified otherwise in an implementation", and if you think about it "drainTo()" does fall in the said category.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

it tells me that there is an else with no if.. why is that?

Always use braces ({}) with your if,else, while, for ... statements as mentioned by the Sun Java coding conventions and you will be able to spot your error.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Have you tried response.sendError(HttpServletResponse.SC_NOT_FOUND)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Is SQLlite recommended for desktop software applications? Mostly browsers and anti-viruses use them. Are there any records based software products using Sqlite?

http://www.sqlite.org/cvstrac/wiki?p=SqliteCompetitors
But of course that is from the SQLite perspective, google should help get the perspective of others.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

What would be the best database option available for such software. We are looking for databases which have decent functionality and not royalty based distribution costs associated with it. e.g Mysql has licensing costs associated with commercial distribution of software. Should postgresql be used as its free to redistribute with your commercial package as well.

Do you really need a full fledged database management system to be bundled with your application, if not then how about SQLite as an alternative here.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Here seems to be your problem bro:-

*-cpu
description: CPU
product: AMD Athlon(tm) 64 Processor 3500+
vendor: Advanced Micro Devices [AMD]

You are using a 32bit OS and corresponding libraries on a 64bit hardware. Although I don't *think* it should be a problem, if you are going for a complete reinstall (or just installing in VirtualBox) I suggest going for 64bit Ubuntu and trying it out.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I downloaded the .bin file. Extracted it. Copied the content of the extracted to folder to /../jvm/java-thingy/jre.Then i restarted the computer.

Yikes !!!, you shouldn't have overwritten that folder, a better option is to copy the extracted folder to some place like "/opt/" so that it will not come in the way of packages you install from the repo.

So i went to the same site and clicked on "verify java version". The browser asked me to install icedtea in order to "display the content of the page correctly".

That test just checks if you have the browser Java plug-in working, when you use the self extracting version of the jre, nothing is installed on your system, just some contents extracted, that is why it did not detect any JVM on your system and asked you to install iced-tea.

Well here is how eclipse is working for me:-
I copied the extracted folder of my JDK (jdk1.6.0_16) to /opt/
Added the following lines to my $HOME/.profile file

PATH=/opt/jdk1.6.0_16/bin:$PATH
export PATH

Logout and Login

After Login to check if your JDK/JRE is the one being used, open terminal and type which java , it should point to the one inside /opt/jdk1.6.0_16/bin.
Once you are sure the new JRE is being picked up, then run eclipse and check !!!

The file may be corrupter, What do you think? I can't find a package in the repos to reinstall this file.
Perhaps you can give …

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Hi, Im trying to match patterns to get A-F and number range 0-9

So like 9D

4EEE

Not 15d

I cannot make any reasonable guess from that on what sort of string should be accepted and what not !!!
But in either case your regular expression (regex) is incorrect, the "*" quantifier suggests that the mentioned pattern may occur zero or more times, so even a blank string would match your regex, if you want to test for a hexadecimal value, I suggesting changing the "*" to a "+" which implies the given pattern appear at least once.

You can see this tutorial to get a solid understanding about regular expressions in Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The System.out.println is run on the server side when the Web Server detects that someone has requested for your JSP page.
Following is in brief the lifecycle of a JSP page:-

When a request is mapped to a JSP page, it is handled by a special servlet that first checks whether the JSP page's servlet is older than the JSP page. If it is, it translates the JSP page into a servlet class and compiles the class. During development, one of the advantages of JSP pages over servlets is that the build process is performed automatically.

Source:http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPIntro4.html
The servlet generates the HTML code (inclusive of your Javascript) which should be displayed and sends it to your browser. The browser is the one that actually runs your Javascript code which shows the alert box, hence the message is printed on the console even before you respond to the alert box.
In fact a simple way to confirm this is by viewing the source of your webpage from the browser (Ctrl + U in firefox), you will notice that none of your java code is present, only the generated HTML and client side Javascript.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

We need to see your JSP or servlet code to be able to pin point anything. Also you have edited out the part of the exception stack trace which would have pointed to the exact line on which the servlet for your JSP encountered the error.

My blind guess is you have called response.getOutputStream() somewhere inside your JSP.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I have seen this article and it is obsolete.Can you suggest something newer?

There were Two Points suggested, Did you look at the second one mentioning the Java Print Service ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You could take a look at the following:-

Printing in Java
(Very old article so information could be obsolete)
Java Print Service (1,2,3)

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well you could write a program to convert the column delimiters to 'commas' and row delimiter to line feed i.e. convert the file to a CSV format, which Excel can read.

However if you want to convert the file to the Excel Proprietary format (XLS) take a look at Apache POI.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The erroneous line is Line 49 in the post, Your "slots" variable inside the main() method is an ArrayList of integers. So slots.get(i) returns an Integer object, and last I checked the javadocs of Integer class did not have any such method.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

A simple way use a Map of type <String,Integer>, so the Key is the String and the value is the number of times it occurs.
When you encounter a word, you can check for its occurrence by invoking in the containsKey() method on that map. If containsKey() returns false for that String it means you have encountered a new word, so add it to the Map and put and Integer value of '1' against it, on the other hand if containsKey() returns true, you have encountered a duplicate, so just acquire the Integer object mapped against that String in your Map and increment it by '1', so that way you are recording the number of times each word occurs.
Finally at the end of your input, your Map will contain all the unique words it encountered in the 'Key' and the number of times each of those words occurred in the corresponding 'Value' entry against that String.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

but dont have much idea abt JNI

Here is a nice place to start out with JNI

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

If you plan on using the Joda Time API, it is as simple as:-

How do I calculate the difference between two dates?

This question has more than one answer! If you just want the number of whole days between two dates, then you can use the new Days class in version 1.4 of Joda-Time.

Days d = Days.daysBetween(startDate, endDate);
  int days = d.getDays();

This method, and other static methods on the Days class have been designed to operate well with the JDK5 static import facility.

If however you want to calculate the number of days, weeks, months and years between the two dates, then you need a Period By default, this will split the difference between the two datetimes into parts, such as "1 month, 2 weeks, 4 days and 7 hours".

Period p = new Period(startDate, endDate);

You can control which fields get extracted using a PeriodType.

Period p = new Period(startDate, endDate, PeriodType.yearMonthDay());

This example will return not return any weeks or time fields, thus the previous example becomes "1 month and 18 days".

For more info, consult the period guide.

Source: http://joda-time.sourceforge.net/faq.html#datediff
Although I do feel it would be an overkill to use the Joda Time API just for this purpose.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Now since you are using HTTP to send messages, you need to consult your provider on how you can acquire the delivery report for messages at your end because unlike SMPP there is no standard HTTP API for sending messages and receiving delivery reports.

Getting the delivery report back from the provider depending on the provider may require you to create another web application onto which he may post the delivery reports of your messages.
Note: The only way to map a message correctly to its delivery report is through the Message Identifier which he(your provider) must be returning to you in the response when you originally submitted the message and also in the delivery report

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well one thing you can try is if you are using the eclipse version from Ubuntu repos, you could try using the one directly from eclipse.org, also the same suggestion for the JVM, try the self extracting version available from Sun(.bin not the rpm.bin) and see if you can get it to work.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Are you sure you haven't by any chance mixed up the "eclipse" version, like 32 bit Eclipse on a 64bit JVM or vice versa ???
BTW which distro of Linux are you on ?
I've had nightmares trying to get my Eclipse run on Ubuntu 7.10 and 8.04, however since 9.04, there haven't been any hassles.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The data download for your newfile.csv, doesn't fail, it is downloaded, try opening that file via notepad or some other text editor and you should get have all the data in it (even if the file has more than 65535 rows), the problem is with 'MS Excel', it cannot handle more than 65k rows.
If you have to use 'MS Excel' to view or manipulate your data then in that case take a look at the Apache POI and write your data into an XLS format (Currently you are using the good ol' comma-separated-version CSV), and use multiple sheets to store your data in case it exceeds 65535 rows.

Note:-
XLS is the name of the extension used when you save the file in Excel '97(-2007) format. The formal format name my guess is BIFF8

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

We may be able to help, but need to know exactly how are you sending those messages ??
Do you have an account with a Sms service provider or you used a GSM Modem, If it is the former then what type of connectivity have you used to send the messages (SMPP, HTTP API etc), without that information we can't help you much !!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Your code in the InheritanceExample class needs to be inside the main method for it to run as you want it. Wrap up all the code inside the InheritanceExample class inside a main as shown below:-

public class InheritanceExample {
  public static void main(String[] args) { //-> My Addition
        Car a=new Car();
        Guzzler g=new Guzzler();
        a.drive(100);
        g.drive(200);
        System.out.println("Car mileage : "+c.odometer);
        System.out.println("Guzzler mileage  :  "+g.odometer);
        g.guzzle();
        if(g instanceof Car)
        {
                System.out.println("Guzzler is a car!!!");
        }
  } //--> My Addition
}

Here is a tutorial on the structure of a basic Java program.


Also another note on the code inside your Car constructor:-

public Car(){
                int odometer=0;
                System.out.println("Car constructed!");
        }

The above chunk of code does not initialize the "odometer" attribute of the Car class, instead it just declares another local variable by the same name and sets it to '0'. The only reason why this hasn't caused a problem is cause Java initializes class level variables to some assumed defaults, example 'int', 'long' are initialized to '0', Object references to null and so on

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

sciprog1 use the "codebase" attribute of the "applet" tag, since I am guessing from the mention of the public_html directory, you are viewing your html page via a web server.

You can find out how to use the codebase attribute here: http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Lets take a look at your actionPerformed() method:-

public void actionPerformed(ActionEvent e){
		
		if(e.getSource().equals(exit)){
			System.exit(0);
		}
		
		String text=((JButton)e.getSource()).getText();
		
		 System.out.println("Value of text " + text);
		 
	   	    try{
	     z=Integer.parseInt(text);
	    if(z==1)
	    	
	    	System.out.println("Its Working");
	    	    
	    try{

            // YIKES, why are you creating your buttons all over again !!!
	    ImageIcon icon[]=new ImageIcon[52];
	    JButton b1[]=new JButton[52];
	    //for(int i=0;i<b1.length;i++){
	    icon[i]=new ImageIcon("D:/WorkSpace/cards/as.gif");
	    //b1[i]= new JButton(Integer.toString(i+1),icon[i]);
	    b1[i]=new JButton(icon[i]); 
	    System.out.println("working");
	     	     
	    }catch(NullPointerException ex){
	    	System.out.println("Invalid use of null refrence");
	    }
	    
	    
	     if(z==2)System.out.println("Thats Good");
	}catch(NumberFormatException ex){
		System .out.println("Invalid Format");
	 }
	}

In your try block why are you creating a new button but you just want to change the icon of an existing button, also that new button, should not be visible as you have not added it to your content pane "pl", you have just created it but done nothing with it.
Instead If you want the icon of the button to change on a click, use the setIcon() method of the AbstractButton class which JButton inherits.
The steps are pretty simple, inside your actionPerformed():-
- Use e.getSource() to get a reference to the clicked button (Which you already seem to know)
- Cast it to a JButton and call the setIcon() method on it.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Sharath,
When you specify "codebase = /WebContent/WEB-INF/" the browser will serach for the Class file of your Applet in the "/WebContent/WEB-INF/" in the directory in which it is running on the client machine where your servlet output is being displayed, it does not look for the class file on the server where your servlet is deployed.

For the browser to look for your applet class on the server, you need a URL of the type "http://...../" to your "codebase".

Here is what I am trying to say.

Also the class file of your applet will need to be moved out from the WEB-INF directory and into another folder from where the browser can access it via the "http://...." URL pattern

Also this should also prove somewhat useful.

Also please use code tags from the next time whenever you post any code.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

new keyword in java is the way of creating an object class - hope this helps

Considering the fact that the O.P. asked the question in Feb 2009, I am guessing he already got the answer or gave up and chose a different career :P

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

I thought the Hash's comparison between two object should be by their equals method,

The comparison is within the hash bucket, if two objects return the same hashcode then only the equality check by equals() takes place as mentioned below on http://www.ibm.com/developerworks/java/library/j-jtp05273.html

The interface contract for Object requires that if two objects are equal according to equals(), then they must have the same hashCode() value. Why does our root object class need hashCode(), when its discriminating ability is entirely subsumed by that of equals()? The hashCode() method exists purely for efficiency. The Java platform architects anticipated the importance of hash-based collection classes -- such as Hashtable, HashMap, and HashSet -- in typical Java applications, and comparing against many objects with equals() can be computationally expensive. Having every Java object support hashCode() allows for efficient storage and retrieval using hash-based collections.

So in the end my advice is check if the hashcode returned by the two objects is the same.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

It seems you are from a Structured Programming background so you need to keep in mind that your main method is static and so can access only static methods and static fields of other classes (or even same class)directly.
Remember Java is object oriented so to invoke your methods as they are now, you will need to first create an object of your class and then invoke the methods on the object, kind of like:-

DouglasPassword passwd = new DouglasPassword();
passwd.validatePWword(word);
.
.
.

Otherwise in case you just want to proceed the way of the Structured Methodology just mark all your methods and fields as static, your code "should" work.
here is a good tutorial if you want to learn more about Object Oriented Programming.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Can you elaborate on that ?

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

The comparison operator in Java is "==" not "=".
Change that on line numbers 7 and 9 and check whether it works.

"=" is the assignment operator, so you are actually setting the value to your array element there.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Look into the Java Mail API

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Why not ask 'they' who wrote the code !!!

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You are not meant to use arrays, does the restriction also imply against use of Collection like ArrayList, HashSet etc

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

JSPs can be deployed on any platform for which a servlet container(Eg Apache Tomcat) has been made or any platform for which you can find an implementation of J2EE Application Server (Eg JBoss, Glassfish).

So it will work on All flavours of Linux, Windows, Solaris etc

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well what you have is a plain ol' syntax error, on your Line No 3:-

Thread mythread1; mythread2

If you want to declare two references on the same line, use a comma (',') to separate the references and not a semicolon (';'), the semicolon is used only to terminate the statement, For example the statements inside your constructor all end if a semicolon.

And regarding your query, I leave that explanation to the javadocs of the Thread class.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

You can also write your own eg. ActionListener that takes in the parent in its constructor so it can access local variables in its 'parent' .. ie. construct your own implementation of an actionlistener that takes in some interface in its constructor (that the parent implements) and work away

Now would you please clarify how does that even connect with the topic under discussion ????
In the first post it is clear the O.P. wanted to just discuss how the local variable in the method was hiding the outer class variable in the inner class.

balmark commented: arrogant fucker +0
BestJewSinceJC commented: erasing balmark's negative rep. +4
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That is not what avinash_545 has asked. He wanted to do that with primitive types (int, float). Not Integer, Double. And even though your code "accidentally" does that, it has already been answered.

This is the second thread where I have seen 'balmark' post something related to the topic but not addressing the actual situation.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

From your post I am a bit lost on what you wish to do, but since the thread topic states you need help on arrays, here is a link to the Java Tutorial on Arrays

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

That is because the charAt() method of the String class returns a "char" and you are assigning it to a String type.
Use the Charater.toString(char), to convert you 'char' to a String type.
Or alternatively you could make your "sample" variable from a String array to a 'char' array.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

i am just asking for a help...//

Well since you know php, then what is stopping you from making classes in Java, apart from the syntax ???

Also here is a tutorial to get you started in classes in Java.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Look you need to show us what effort you have put in, in analysing the problem to get to the solution, Most people here are not going to throw the solution at you, You need to show us the effort you have put in solving the problem, only then we will lend a hand.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well Sorry to burst the bubble here, But there is a well known work around for the problem you mentioned. If you need to access the Class member in your inner class in the above situation use the following syntax:-

<Outer_Class_Name>.this.<Member_Name>

The following example should drive the point home:-
(Note have used a Method Local Inner Class instead of an anonymous inner class just to simplify the example)

public class OuterClassDemo {
  // The displayText variable of the OuterClass
  private String displayText="OuterDisplay";

  public OuterClassDemo() {
    // Here we are declaring the local displayText variable,
    // it has been declared as "final" as I want to access it
    // inside the inner class methods
    final String displayText="LocalDisplay";
    class InnerClass {
      public void show() {
        System.out.println("OuterDisplay : " + OuterClassDemo.this.displayText);
        System.out.println("Local DisplayText : " + displayText);
      }
    };

    // Instantiate the inner class and invoke the show() method.
    InnerClass ic = new InnerClass();
    ic.show();
  }

  public static void main(String[] args) {
    new OuterClassDemo();
  }
}

The output the above program would give is:-

stephen@home:~$ java OuterClassDemo
OuterDisplay : OuterDisplay
Local DisplayText : LocalDisplay

So as you see there is no problem in accessing the "displayText" variable of the outer class, even though the method/constructor in which the class is declared has a local variable with the same name.

kvass commented: Solid, insightful post. Good catch :) +1
stephen84s 550 Nearly a Posting Virtuoso Featured Poster

how we can send binary sms to any mobile particularly nokia mobile from pc using smpp...

Since you mentioned SMPP, I am assuming you know about UDH, and the providers and what are binary messages.
Here is a link on how to send WAP push messages, it does not deal with the SMPP part it deals more with how the message should be encoded, and from my days in the messaging domain we used to consider WAP push a type of a binary message, so this should hopefully shed some light on the topic for you.

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Well your IDE has already suggested four possible reasons for the problem as mentioned below :-

Possible reasons include:
- IDE timeout: refresh the server node to see if it's running now.
- Port conflicts. (use netstat -a to detect possible port numbers already used by the operating system.)
- Incorrect server configuration (domain.xml to be corrected manually)
- Corrupted Deployed Applications preventing the server to start.(This can be seen in the server.log file. In this case, domain.xml needs to be modified).
- Invalid installation location.

Have you checked which is the actual reason by checking the suggestions it has provided ???

stephen84s 550 Nearly a Posting Virtuoso Featured Poster

Any suggestions / code examples for Encryption/Decryption of files(any file format) in java.
command line args - <inputfilename> <outputfilename>

Show us what you have tried first please.

Salem commented: Well said +18