Saidul Islam

Greenhorn
+ Follow
since Dec 05, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Saidul Islam

Originally posted by Asher Tarno:
i have an expirience with hebrew. i did the next thing, but this helps only in case of ie:
run this method on the string you have
getBytes("UTF16","Cp1255").substring(2)
the result is visible in internet explorer.
try it, and tell me if it worked and for what language.


hmm... this might work. In my example, I can probly use something like
new String(req.getParameter("nickname").getBytes("UTF-16")).substring(2)
I wonder what the memory utilization going to look like if I use it in a heavy traffic web site.
18 years ago

Originally posted by Bhushan Jawle:
Hi,
To print non-ascii characters on console, I think you need to have an OS which supports those characters. I had similar problem with Japanese characters, I used to check those by writing them to an HTML file with proper encoding(Shift_JIS in my case).
Hope that helps.
Bhushan



I guess I am not sure what encoding I should be using. That's the reason I used UTF8 and thought it would include everything.
18 years ago
Does anyone know how to handle foreign characters in a request object? In my case, I pass foreign chars from jsps or some presentation layer to some servlet or business logic. To keep the conversation simple say, I want to print these special chars in console or log file or even in the resulting servlet. How do u print that raw data? In my case, it looks like the foreign characters are getting replaced by '?' marks.
Before doing anything to the request object, I call setCharacterEncoding("UTF-8") thought UTF8 is the mother of all and something magical will happen (yea I wish..). It actually gets rid off those foreign chars and any chars after them.
I am doing something like
<pre>
try
{
req.setCharacterEncoding("UTF-8");
}
catch (java.io.UnsupportedEncodingException ue)
{
//do nothing
}
System.out.println(req.getCharacterEncoding());
System.out.println(">" + req.getParameter("firstName") + "<");
</pre>
Here is the input I am trying
<pre>
�������
</pre>
I hope the input value is printed here the way I want.
18 years ago
Thanks Nate. It worked fine. And yes it looks like I have to use System.exit(0) to break out of the program.
20 years ago
Sorry guys if I am posting it in the wrong forum.
I am trying to convert a text value (String) to an image (.jpg). My program seems to be working somewhat. It's creating a blank (whiite background) .jpg file, without my string value "Saidul Islam". I can open the file in any image editor. it just doesn't have the string I am trying to print.
And the strange part is that the program is not even terminating.
Here is the output I get when I run it
<pre>
C:\test>java Text2Image
gets here
flushed
closed
final
dispose
remove notify
done!
</pre>
it's of course printing the last line but the program is not terminating. I have been working on this since yesterday. and my brain is not functioning anymore on this. So I ask for your help.
what am I doing wrong and how do I get this working.
Here is my program-
<pre>
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;

public class Text2Image {
public static void main(String args[]) {
Frame myFrame = null;
Graphics2D myGraphics = null;
try {
myFrame = new Frame();
myFrame.addNotify();
BufferedImage buffImage = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedImage buff2Image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("text.jpg"));
Image offImage = myFrame.createImage(400, 200);
//myGraphics = buffImage.getGraphics();
myGraphics = buffImage.createGraphics();
myGraphics.setFont(new Font("Serif", Font.ITALIC, 48));
myGraphics.setColor(Color.red);
myGraphics.drawString("Saidul Islam", 10, 50);
myGraphics.drawImage(offImage, 0, 0, myFrame);
buffImage.createGraphics().drawImage(buffImage, 0, 0, myFrame);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(buffImage);

//JpegEncoder jpg = new JpegEncoder(offImage, 80, bos);
//jpg.Compress();

System.out.println("gets here");
bos.flush();
System.out.println("flushed");
bos.close();
System.out.println("closed");

buffImage.flush();
buff2Image.flush();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
System.out.println("final");
if (myGraphics != null) {
myGraphics.dispose();
System.out.println("dispose");
}
if (myFrame != null) {
myFrame.removeNotify();
System.out.println("remove notify");
}
}
System.out.println("done!");
} //end of main method
} //end of Text2Image class
</pre>

Thanks for your help!
20 years ago
Sorry guys if I am posting it in the wrong forum.
I am trying to convert a text value (String) to an image (.jpg). My program seems to be working somewhat. It's creating a blank (whiite background) .jpg file, without my string value "Saidul Islam". I can open the file in any image editor. it just doesn't have the string I am trying to print.
And the strange part is that the program is not even terminating.
Here is the output I get when I run it
<pre>
C:\test>java Text2Image
gets here
flushed
closed
final
dispose
remove notify
done!
</pre>
it's of course printing the last line but the program is not terminating. I have been working on this since yesterday. and my brain is not functioning anymore on this. So I ask for your help.
what am I doing wrong and how do I get this working.
Here is my program-
<pre>
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;

public class Text2Image {
public static void main(String args[]) {
Frame myFrame = null;
Graphics2D myGraphics = null;
try {
myFrame = new Frame();
myFrame.addNotify();
BufferedImage buffImage = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedImage buff2Image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("text.jpg"));
Image offImage = myFrame.createImage(400, 200);
//myGraphics = buffImage.getGraphics();
myGraphics = buffImage.createGraphics();
myGraphics.setFont(new Font("Serif", Font.ITALIC, 48));
myGraphics.setColor(Color.red);
myGraphics.drawString("Saidul Islam", 10, 50);
myGraphics.drawImage(offImage, 0, 0, myFrame);
buffImage.createGraphics().drawImage(buffImage, 0, 0, myFrame);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(buffImage);

//JpegEncoder jpg = new JpegEncoder(offImage, 80, bos);
//jpg.Compress();

System.out.println("gets here");
bos.flush();
System.out.println("flushed");
bos.close();
System.out.println("closed");

buffImage.flush();
buff2Image.flush();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
System.out.println("final");
if (myGraphics != null) {
myGraphics.dispose();
System.out.println("dispose");
}
if (myFrame != null) {
myFrame.removeNotify();
System.out.println("remove notify");
}
}
System.out.println("done!");
} //end of main method
} //end of Text2Image class
</pre>

Thanks for your help!
20 years ago
Sorry guys if I am posting it in the wrong forum.
I am trying to convert a text value (String) to an image (.jpg). My program seems to be working somewhat. It's creating a blank (whiite background) .jpg file, without my string value "Saidul Islam". I can open the file in any image editor. it just doesn't have the string I am trying to print.
And the strange part is that the program is not even terminating.
Here is the output I get when I run it
<pre>
C:\test>java Text2Image
gets here
flushed
closed
final
dispose
remove notify
done!
</pre>
it's of course printing the last line but the program is not terminating. I have been working on this since yesterday. and my brain is not functioning anymore on this. So I ask for your help.
what am I doing wrong and how do I get this working.
Here is my program-
<pre>
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import com.sun.image.codec.jpeg.*;

public class Text2Image {
public static void main(String args[]) {
Frame myFrame = null;
Graphics2D myGraphics = null;
try {
myFrame = new Frame();
myFrame.addNotify();
BufferedImage buffImage = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedImage buff2Image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("text.jpg"));
Image offImage = myFrame.createImage(400, 200);
//myGraphics = buffImage.getGraphics();
myGraphics = buffImage.createGraphics();
myGraphics.setFont(new Font("Serif", Font.ITALIC, 48));
myGraphics.setColor(Color.red);
myGraphics.drawString("Saidul Islam", 10, 50);
myGraphics.drawImage(offImage, 0, 0, myFrame);
buffImage.createGraphics().drawImage(buffImage, 0, 0, myFrame);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
encoder.encode(buffImage);

//JpegEncoder jpg = new JpegEncoder(offImage, 80, bos);
//jpg.Compress();

System.out.println("gets here");
bos.flush();
System.out.println("flushed");
bos.close();
System.out.println("closed");

buffImage.flush();
buff2Image.flush();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
System.out.println("final");
if (myGraphics != null) {
myGraphics.dispose();
System.out.println("dispose");
}
if (myFrame != null) {
myFrame.removeNotify();
System.out.println("remove notify");
}
}
System.out.println("done!");
} //end of main method
} //end of Text2Image class
</pre>

Thanks for your help!
20 years ago
got it!
Looks like you can use toHexString() method of either Long or Integer object.
20 years ago
is there any method for converting int, long, etc. to Hexcode?
20 years ago
when I call java.rmi.server.UID() it returns soemthing like the following
62eec8:e63f20483f:-8000
62eec8:e63f20483f:-7fff
62eec8:e63f20483f:-7ffe
62eec8:e63f20483f:-7ffd
62eec8:e63f20483f:-7ffc
62eec8:e63f20483f:-7ffb
62eec8:e63f20483f:-7ffa
62eec8:e63f20483f:-7ff9
62eec8:e63f20483f:-7ff8
62eec8:e63f20483f:-7ff7
my question is what are these values or how are they getting generated. I know they are unique values. what are the three portions?
Thanks
20 years ago
Is there anyway to get the serial number/address from NIC card in java?
is there anyway I can get the process id of an application in Java without using JNI?
something like
public class SomeClass {
public SomeClass() {
//print the process id of this
}
}
20 years ago
Did anyone work on any unique key generation algorithm that is not based on timestamp? Maybe based on the combnation of timestamp and random numbers, or database driven or any other mechanishm.
Would you like to share your thoughts on this?
Forgive me if the question sounds not related to the forum. Maybe we can ask JavaRanch host to create a new forum for discussing algorithm/pattern in Java.
------------------
<b>JStar</b>
20 years ago
well...
in my case, it doesn't matter what I try, either C (.c) or C++ (.cpp), I still get the same error

Here is my small hello world kind java app
-----------------------
//DisplayName.java
public class DisplayName {
public native void display();
static {
System.out.println("gets here2");
System.out.println(System.getProperty("java.library.path"));
try {
System.loadLibrary("libdispname.so");
}
catch (UnsatisfiedLinkError e) {
System.out.println("Error: " + e.getMessage());
}
} //End of static block
public static void main(String[] args) {
System.out.println("gets here1");
new DisplayName().display();
} //End of my main method
} //End of DisplayName class
----------------------------------

Here is my DisplayName.h
-------------------------------------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class DisplayName */
#ifndef _Included_DisplayName
#define _Included_DisplayName
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: DisplayName
* Method: display
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_DisplayName_display
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
-----------------------------------------------------------
Here is my dispname.cpp
----------------------------------------------------
#include <jni.h>
#include "DisplayName.h"
#include <iostream.h>
JNIEXPORT void JNICALL Java_DisplayName_display(JNIEnv *env, jobject obj)
{
cout << "Hello Saidul!";<br /> return;<br /> }<br /> --------------------------------------------------------------<br /> this is how I am trying to make the .so<br /> sislam@w2/javaexpm/jni> CC -G -I/usr/java1.2/include -I/usr/java1.2/include/solaris dispname.cpp -o libdispname.so<br /> <br /> it creates the libdispname.so fine<br /> when I run<br /> sislam@w2/javaexpm/jni> java DisplayName
i get the following
gets here2
/usr/java1.2/bin/../jre/bin/../lib/sparc:/export/home/sislam/javaexpm/jni:/usr/l
ib
Error: no libdispname.so in java.library.path
gets here1
Exception in thread "main" java.lang.UnsatisfiedLinkError: display
at DisplayName.main(DisplayName.java:19)
20 years ago
Hi everyone-
I am trying to run this simple app that uses a native method. Everthing is created and compiled fine.
I compiled the my .java.
I created the .h
I created my .cpp
I created my .so
So, everything is cool. I run my app like...
java myjavaapp
and it gives me
Exception in thread "main" java.lang.UnsatisfiedLinkError: no dispname in java.library.path
ok so I set my $LD_LIBRARY_PATH and exported it. and I still get the same thing.
what am i missing?
thanks
20 years ago