How can I use MD5 digest in Java?
Hello mates,
I tried to use MessageDigest class to do a md5 digest to a String:
MessageDigest md = MessageDigest.getInstance("MD5");
byte toChapter1;
byte toChapter2;
try {
md.update(toChapter1);
MessageDigest tc1 = md.clone();
byte[] toChapter1Digest = tc1.digest();
md.update(toChapter2);
} catch (CloneNotSupportedException cnse) {
throw new DigestException("couldn't make digest of partial content");
}But its not working. I dnt know why..
REGARDS,
Elton
You don't say what it does not do that is should or what it should do that it does not! Also, I don't understand why you are cloning the MessageDigest object!
Similar Messages
-
How can i use Unix database in java?
How can i use Unix database in Java?
Message was edited by:
JProI have not a clue about FoxPro, but the db then is FoxPro and not Unix. The better question would be "How do I connect to FoxPro DB running on Unix with JDBC?".
My answer to that would be, search the Internet for a JDBC driver. -
How can i use C/Javascript/php/Java in flex?
can i embed these language into my flex project?
since i have to check harddisk space, free memory remain. Also, i need to check the pixel of photos before the photos becoming bitmapdata
please help~saipanBETTY0509 wrote:
Subject: How can i use C/Javascript/php/Java in flex?
can i embed these language into my flex project?
You can't. Why do you want to do this?
saipanBETTY0509 wrote:
since i have to check harddisk space, free memory remain. Also, i need to check the pixel of photos before the photos becoming bitmapdata
I think what this means is "I want to check to see how much hard disk space is available. Also, I need to check the pixel dimensions of an image."
Is that right?
There is no way in the Flash Player (as far as I know) that you can determine the amount of free disk space. However, in AIR you can use air.File.applicationStorageDirectory.spaceAvailable to determine the storage space available in the application storage directory.
As far as determining the dimensions of an image, there are plenty of good resources out there on that. Maybe this one will be helpful to you?
http://www.yswfblog.com/blog/2008/12/22/flash-10-experiments-the-warholizer-loading-and-pr ocessing-local-images/
-Josh -
How can I use Servlets on Sun Java System WebServer 6.1
Hi
This is Khurram,
I have just downloaded, and installed "Sun One Java System Web Server 6.1" on WindowsXP. This is installed and working properly on my system. But I want to use Servlet technology on this server, even I did download it just for working on servlets. Before it, I was using typical JavaWebServer2.0 for this purpose.
Any ways.
Can any one tell me, how can I do this on "Java System Web Server 6.1".
Thanks
any help will be appriciated
regards
KhurramThanks for your such action.
Actually I have installed it since 2 days, and have read throughly the documentation of WebServer, But Only the Link for this purpose is provided "Programmer's Guide to Web Applications", Now I have just searched for it and found only "Programmer's Guide" .PDF format. I have just read it out now, But here also provided a small refference to see "Programmer's Guide to Web Applications". Now I have just the problem that where to find it.
Please, tell me if you have some solution to my problem
or atleast tell me where to find the refference "Programmer's Guide to Web Applications". I tried but only found "Programmer's Guide" for Sun Web Server 6.1.
Thanks any way to give some time.
Khurram -
How can I use JVM instructions from Java classes?
Hello,
I want to use JVM instructions in my Java classes. How can I achieve this?
Should I include a library to my project or something else?What on earth are you talking about?
-
How can I use COM technology in java.
I have one assignment in to which I have to build GUI in java and back end processing in VC. Is that possible.?? IF yes How ??
COM componet might be one solution but how todo that in java.There's a package out there somewhere for doing COM from java, google should find it for you.
Or you can create a DLL with your C++ code and write it to be invoked by JNI from Java. -
How can I use MS Word within java programming
Hi everyone!
I am developing a Java program that will take data
from an Access 2000 database, and manipulate it,
display the results graphically and in tables. The
challenge for me is that I want the program insert the
graphics and tables into the MS Word template and then
prompt me to save it as a word * .doc. Do you know
of any articles or sources of sample code on how to do
this. The Java environment is Java2, JDK 1.3,
JBuilder4. The OS environment is XP.
Regards,
FaradHi, I also need that package. my e-mail is [email protected] Plese send me that. Thanks in advance
I have a package that will do this for you. I just
need to get your email to send an attachment and
examples. -
How can I use UNIX "ls -lt" command in JAVA?
I have a piece of java code whose function is to search for all
the files in a directory and attach the time of the file creation.
How can I do it? Also, I know that in UNIX, "ls -lt" will give me
all the file names and the creation times. So how can I use "ls -lt"
in Java?O,I see you have notice my friend tsith,its not really about what language is better its about what language is better to start off with,this is the twist and the diffrents to other postings and so far I have not seen a good argument saying y java is a better language to start off with.Anyways the ? still stands is java a better language to start off with then c/c++???.If you ask me c/c++ is better and I am just waiting for a good argument to give my reasons.Anysways good to see you are still around tsith ;-).
-
How can I using functions implicit in dll file in java code ?
How can I using functions implicit in dll file in java code ?
I'm developing a program that interfacing with fingerprint hardware.
I have the finger print already, and I have to the SDK that have all functions for managing this fingerprint.
These SDK functions are represented in dll files.
I want to know how can I use these functions in java code .
I looked on this link of sun forums :
http://forum.java.sun.com/thread.jspa?threadID=305171&messageID=1215613
but I don't Understand the meaning of native code.
Thanks for help.please please please please please please please please help me:
After reading a lot of articles, tutorials, and overviews about JNI (Java Native Interface)
I found that these steps
1. Develop the Java code
2. Compile the Java code to a class file
3. Generate the header file
4. Implement the native method
5. Create the shared library or DLL
6. Run the Java program
Is the common steps in JNI development
The most powerful link was
http://java.sun.com/docs/books/jni/html/start.html
and
http://www.netbeans.org/kb/55/beginning-jni-part2.html
and the pdf oh this link
http://www.ibm.com/developerworks/edu/j-dw-javajni-i.html requiring IBM registration to download it.
But I have already the DLL, and want to the stright forward way to use its functions by java code only.
I don not to write any C++ code .
Is this possible???????????????????????????????
The name of these dll is �zkemsdk.dll�
It developed by ZKSOFTWARE company for managing a finger print �NP1500A�of
http://www.napcogulfsecurity.com/finger_print.asp
thanks for help -
How can i execute Spaces API in java main class?
Hi
I am able to execute Spaces API through portal application. However if i try to execute it in java main class, its throwing an exception
"SEVERE: java.io.FileNotFoundException: .\config\jps-config.xml (The system cannot find the path specified)"
oracle.wsm.common.sdk.WSMException: WSM-00145 : Keystore location or path can not be null or empty; it must be configured through JPS configuration or policy configuration override.
How can i set this path, so that i can execute Spaces API from java main class.
Need this main class to configure in cron job, to schedule a task.
Regards
RajHi Daniel
Currently i have implemented create functionality in my portal application using Spaces API, which is working fine. Now the requirement is, i need to implement a "Cron Job" to schedule a task, which will execute to create space(for example once in a week). Cron job will execute only the main method. So I have created java main class, in which I have used Spaces API to perform create space operation. Then it was giving exception.
Later I understood the reason, as I am executing the Space API with a simple JSE client, its failing since a simple java program has no idea of default-keystore.jks, jps-config.xml, Security Policy. Hence i have included those details in main class. Now I am getting new error,
SEVERE: WSM-06303 The method "registerListener" was not called with required permission "oracle.wsm.policyaccess"
For your reference i have attached the code below, please help. How can i use Spaces API in java main method(i mean public static void main(String[] args) by giving all required information.
public static void main(String[] args) throws InstantiationException,
GroupSpaceWSException,
SpacesException {
Class2 class2 = new Class2();
GroupSpaceWSContext context = new GroupSpaceWSContext();
FactoryFinder.init(null);
context.setEndPoint("http://10.161.226.30/webcenter/SpacesWebService");
context.setSamlIssuerName("www.oracle.com");
context.setRecipientKeyAlias("orakey");
Properties systemProps = System.getProperties();
systemProps.put("java.security.policy","oracle/wss11_saml_or_username_token_with_message_protection_client_policy");
systemProps.put("javax.net.ssl.trustStore","C:\\Oracle\\Middleware11.1.7\\wlserver_10.3\\server\\lib\\cacerts.jks");
systemProps.put("oracle.security.jps.config","C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\jps-config.xml");
systemProps.put("javax.net.ssl.keyStore",C:\\Oracle\\Middleware11.1.7\\user_projects\\domains\\workspace\\system11.1.1.7.40.64.93\\DefaultDomain\\config\\fmwconfig\\consumer.jks");
systemProps.put("javax.net.ssl.keyStorePassword", "Test12");
System.setProperties(systemProps);
GroupSpaceWSClient groupSpaceWSClient;
try {
groupSpaceWSClient = new GroupSpaceWSClient(context);
System.out.println("URL: " +
groupSpaceWSClient.getWebCenterSpacesURL());
//delete the Space
List<String> groupSpaces = groupSpaceWSClient.getGroupSpaces(null);
System.out.println("GroupSpaces:: " + groupSpaces.size());
} catch (Exception e) {
Regards
Raj -
How can i use or embed the ' C' language in java
thanks a lot friends for your suggestion on using 'c' language to implement the control of the keyboard ie. to prevent a key stroke of : ctrl+alt+delete keys from closing a running java application. i was advised that it won't be possible to implement this with java language, the use of 'C' language was suggested. i then wish to ask the following:
1. how can i use 'C'language in a java program and be able to compile to program so that the resultant program can help me prevent the closing of my java-application when the user of the application presses the following keys : ctrl+alt+delete. i don't even know the c language at all. how can i start and how can i combine the resultant code with java.
2. i'm thinking of creating an application that retrieves information from a database, like microsoft sql or oracle, and displays the resultant data from a table, say STUDENT TABLE, in a java application using the JTable class. i don't even know how to use this JTable but i've seen it used and know it will suit what i have in mind.
3. how can i make the table dynamic, ie. how can i make the table to immediately register / show the result of an update to the 'STUDENT' table in the database.
4. THANKS FOR YOUR HELP IN ADVANCE. i will most appreciate it if you can give me a sample code or a site where i download one. once again thanks.Good luck disabling Ctrl+Alt+Del! I've read quite a bit about it, and at least on Windows 2000 (not sure about NT) or higher, disabling it is next to impossible. Problem is CAD is a system command, and the OS doesn't even send the keys to the active program. Ctrl+Alt+Del is handled by the GINA (Graphical Identification and Authentication) DLL installed on the system. You'll have to write and export the functions you need and change the GINA DLL used by the system to your own. Bear in mind that any small mistake in the dll can cause you to lose access to your computer if you haven't taken precautions!
On Windows 95/98, disabling Ctrl+Alt+Del is fairly easy as you just have to write some simple native code to fool the system that a password protected screensaver is running.
I've provided a link regarding winlogon and GINA here, but you've been forewarned!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/winlogon_and_gina.asp -
How can I use Seeburger java functions on SAP XI's user defined functions?
Hi All,
As my title implies; how can I use Seeburger java functions on SAP XI's user defined functions? I've tried searching over the net in tutorials regarding this topic but I failed to find one; can someone provide me information regarding my question? thanks very much.
best regards,
MikeHi Mike !
You should check your documentation about which java classes you need to reference in the "import" section of your UDF. And also deploy the java classes into the java stack or include them as a imported archive in integration repository...it should be stated in the seeburger documentation.
What kind of functions are you trying to use?
Regards,
Matias. -
How can I use XStream to persist complicated Java Object to XML & backward
Dear Sir:
I met a problem as demo in my code below when i use XTream to persist my Java Object;
How can I use XStream to persist complicated Java Object to XML & backward??
See
[1] main code
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class PhoneList {
ArrayList<PhoneNumber> phones;
ArrayList<Person> person;
private PhoneList myphonelist ;
private LocationTest location;
private PhoneList(String name) {
phones = new ArrayList<PhoneNumber>();
person = new ArrayList<Person>();
public ArrayList<PhoneNumber> getphones() {
return phones;
public ArrayList<Person> getperson() {
return person;
public void addPhoneNumber(PhoneNumber b1) {
this.phones.add(b1);
public void removePhoneNumber(PhoneNumber b1) {
this.phones.remove(b1);
public void addPerson(Person p1) {
this.person.add(p1);
public void removePerson(Person p1) {
this.person.remove(p1);
public void BuildList(){
location = new LocationTest();
XStream xstream = new XStream();
myphonelist = new PhoneList("PhoneList");
Person joe = new Person("Joe, Wallace");
joe.setPhone(new PhoneNumber(123, "1234-456"));
joe.setFax(new PhoneNumber(123, "9999-999"));
Person geo= new Person("George Nixson");
geo.setPhone(new PhoneNumber(925, "228-9999"));
geo.getPhone().setLocationTest(location);
myphonelist.addPerson(joe);
myphonelist.addPerson(geo);
public PhoneList(){
XStream xstream = new XStream();
BuildList();
saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
public void saveStringToFile(String fileName, String saveString) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(
new FileWriter(fileName));
try {
bw.write(saveString);
finally {
bw.close();
catch (IOException ex) {
ex.printStackTrace();
//return saved;
public String getStringFromFile(String fileName) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
br = new BufferedReader(
new FileReader(fileName));
try {
String s;
while ((s = br.readLine()) != null) {
// add linefeed (\n) back since stripped by readline()
sb.append(s + "\n");
finally {
br.close();
catch (Exception ex) {
ex.printStackTrace();
return sb.toString();
public String convertToXML(PhoneList phonelist) {
XStream xstream = new XStream(new DomDriver());
xstream.setMode(xstream.ID_REFERENCES) ;
return xstream.toXML(phonelist);
public static void main(String[] args) {
new PhoneList();
}[2].
import java.io.Serializable;
import javax.swing.JFrame;
public class PhoneNumber implements Serializable{
private String phone;
private String fax;
private int code;
private String number;
private String address;
private String school;
private LocationTest location;
public PhoneNumber(int i, String str) {
setCode(i);
setNumber(str);
address = "4256, Washington DC, USA";
school = "Washington State University";
public Object getPerson() {
return null;
public void setPhone(String phone) {
this.phone = phone;
public String getPhone() {
return phone;
public void setFax(String fax) {
this.fax = fax;
public String getFax() {
return fax;
public void setCode(int code) {
this.code = code;
public int getCode() {
return code;
public void setNumber(String number) {
this.number = number;
public String getNumber() {
return number;
public void setLocationTest(LocationTest bd) {
this.location = bd;
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(location);
f.getContentPane().add(location.getControls(), "Last");
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
public LocationTest getLocationTest() {
return location;
}[3].
package test.temp;
import java.io.Serializable;
public class Person implements Serializable{
private String fullname;
@SuppressWarnings("unused")
private PhoneNumber phone;
@SuppressWarnings("unused")
private PhoneNumber fax;
public Person(){
public Person(String fname){
fullname=fname;
public void setPhone(PhoneNumber phoneNumber) {
phone = phoneNumber;
public void setFax(PhoneNumber phoneNumber) {
fax = phoneNumber;
public PhoneNumber getPhone() {
return phone ;
public PhoneNumber getFax() {
return fax;
public String getName() {
return fullname ;
public void setName(String name) {
this.fullname = name;
public String toString() {
return getName();
}[4]. LocationTest.java
package test.temp;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class LocationTest extends JPanel implements ChangeListener
Ellipse2D.Double ball;
Line2D.Double line;
JSlider translate;
double lastTheta = 0;
public void stateChanged(ChangeEvent e)
JSlider slider = (JSlider)e.getSource();
String name = slider.getName();
int value = slider.getValue();
if(name.equals("rotation"))
tilt(Math.toRadians(value));
else if(name.equals("translate"))
moveBall(value);
repaint();
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(ball == null)
initGeom();
g2.setPaint(Color.green.darker());
g2.draw(line);
g2.setPaint(Color.red);
g2.fill(ball);
private void initGeom()
int w = getWidth();
int h = getHeight();
int DIA = 30;
int padFromEnd = 5;
line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
double x = line.x2 - padFromEnd - DIA;
double y = line.y2 - DIA;
ball = new Ellipse2D.Double(x, y, DIA, DIA);
// update translate slider values
int max = (int)line.getP1().distance(line.getP2());
translate.setMaximum(max);
translate.setValue(max-padFromEnd);
private void tilt(double theta)
// rotate line from left end
Point2D pivot = line.getP1();
double lineLength = pivot.distance(line.getP2());
Point2D.Double p2 = new Point2D.Double();
p2.x = pivot.getX() + lineLength*Math.cos(theta);
p2.y = pivot.getY() + lineLength*Math.sin(theta);
line.setLine(pivot, p2);
// find angle from pivot to ball center relative to line
// ie, ball center -> pivot -> line end
double cx = ball.getCenterX();
double cy = ball.getCenterY();
double pivotToCenter = pivot.distance(cx, cy);
// angle of ball to horizon
double dy = cy - pivot.getY();
double dx = cx - pivot.getX();
// relative angle phi = ball_to_horizon - last line_to_horizon
double phi = Math.atan2(dy, dx) - lastTheta;
// rotate ball from pivot
double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
lastTheta = theta; // save theta for next time
private void moveBall(int distance)
Point2D pivot = line.getP1();
// ball touches line at distance from pivot
double contactX = pivot.getX() + distance*Math.cos(lastTheta);
double contactY = pivot.getY() + distance*Math.sin(lastTheta);
// find new center location of ball
// angle lambda = lastTheta - 90 degrees (anti-clockwise)
double lambda = lastTheta - Math.PI/2;
double x = contactX + (ball.width/2)*Math.cos(lambda);
double y = contactY + (ball.height/2)*Math.sin(lambda);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
JPanel getControls()
JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
translate = getSlider("distance from end", "translate", 0, 100, 100,25, 50);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(rotate);
panel.add(translate);
return panel;
private JSlider getSlider(String title, String name, int min, int max,
int value, int minorSpace, int majorSpace)
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
slider.setBorder(BorderFactory.createTitledBorder(title));
slider.setName(name);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(minorSpace);
slider.setMajorTickSpacing(majorSpace);
slider.setPaintLabels(true);
slider.addChangeListener(this);
return slider;
}OK, My questions are:
[1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
[2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
Thanks a lot!!Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.
-
How can I use regular expression to open files of certain types in java?
Ok this is the problem I am facing:
I have a command line input of something like "/usr/foo/bar/*.html"
and there are multiple files in that folder that end with .html.
How can I use the input to go through/open all the .html files in Java?
Help would be greatly appreciated thanks!Or if you have to do it in java, check out the interfaces java.io.FileFilter and java.io.FileNameFilter
http://home.tiscali.nl/~bmc88/java/sbook/0128.html
class HTMLFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(".html"));
}Cheers,
evnafets -
How can we use java variable in javascript code on JSP page?
How can we use java variable in javascript code on JSP page?
Pls helpThink about it:
JSP/Java is executed on the Server and produces HTML+JavaScript.
Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
Obviously there's no way to access a Java variable directly from JavaScript.
What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable.
Maybe you are looking for
-
HP Deskjet 3050 All-in-one J610 series
My printer display is showing an error message: scanner failure, unable to copy or scan. It seems very loud when I turn the printer on. I am, however, able to print copies that are sent through my laptop.
-
After Effects CC 2014 only using 30% of CPU when rendering
I've scoured the internet for details but there's surprisingly little help when it comes to After Effects and performance. Basically, I built a new workstation awhile ago with the hopes of really speeding up my video editing as I was starting to do a
-
Will not restore or connec to itunes - just get the itunes logo and usb cale display on screen
ipod touch will not restore or connec to itunes - just get the itunes logo and usb cable display on screen
-
Moving from CS 5.5 Design Premium to CS 6 Design & Web Premium on Mac
I recently purchased CS6 Web Design & Premium for MAC. I'm running Mac version OS X Lion 10.7.5. The MAC currently has CS5.5 Design Premium installed on it. I purchased the upgrade because I was eligible at the discounted upgrade price. Should I unin
-
I have problem with my i phone
i have problem with my i phone,charges not, not come on at all the screen is dead,even when i try to synchronize with i tunes is dead to.please help me.