|
1. Learn basics of java
2. Learn basics of databases
3. Learn basics of eclipse
4. Learn basics of access database via java.
5. Design application
6. Find java library that does charts. Learn how to use it.
7. Write application
8. Learn basics of Android programming
9. Learn basics of 'using' database on Android
10. Write Android application.
Step 9 might actually involve learning serving programming which involves several other steps.
|
|
|
|
|
You missed step 0: don't post the same question in four places on the same site!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I wrote some code to insert custom annotations into a TIFF file, but I am having two problems.
First, the annotation description does not appear to be written correctly to the TIFF file, though the value is fine. I used AsTiffTagViewer to inspect the file, so it is possible that program does read descriptions for custom metadata.
Secondly, and this is more important, the exact same code does not work on Linux (runs w/o error but the annotations are not written). It runs fine on Windows 7. Below is a list of the jar files I have tried adding to the class path:
imageio-ext-tiff-1.1.10.jar
jai_codec.jar
jai_core.jar
jai_imageio-1.1.jar
mlibwrapper_jai.jar
Any help w/ these two issues would be appreciated. The code is below (assume a multi-page TIFF with 3 embedded images).
Thanks in advance!
Doug
package consoleapp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.stream.FileImageOutputStream;
import javax.imageio.stream.ImageInputStream;
import com.sun.media.imageio.plugins.tiff.TIFFDirectory;
import com.sun.media.imageio.plugins.tiff.TIFFField;
import com.sun.media.imageio.plugins.tiff.TIFFTag;
import com.sun.media.imageio.plugins.tiff.TIFFTagSet;
public class TIFFAnnotator3 {
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream("/tmp/input.TIF");
ImageInputStream iis = ImageIO.createImageInputStream(fis);
ImageReader imageReader = ImageIO.getImageReadersBySuffix("tiff").next();
imageReader.setInput(iis);
FileImageOutputStream fos = new FileImageOutputStream(new File("/tmp/output.TIF"));
ImageWriter imageWriter = (ImageWriter) ImageIO.getImageWritersBySuffix("tiff").next();
imageWriter.setOutput(fos);
int imageCount = imageReader.getNumImages(true);
for(int j = imageCount - 1; j >= 0; j--) {
BufferedImage image = imageReader.read(j);
IIOMetadata imageMetaData = imageReader.getImageMetadata(j);
TIFFDirectory dir = TIFFDirectory.createFromMetadata(imageMetaData);
List tags = new ArrayList();
TIFFTag tag1 = new TIFFTag("FirstName", 65001, TIFFTag.TIFF_ASCII);
tags.add(tag1);
TIFFTag tag2 = new TIFFTag("LastName", 65002, TIFFTag.TIFF_ASCII);
tags.add(tag2);
TIFFTagSet tagSet = new TIFFTagSet(tags);
dir.addTagSet(tagSet);
String[] tag1values = new String[1];
String[] tag2values = new String[1];
switch(j) {
case 0:
tag1values[0] = "Arthur";
tag2values[0] = "Dent";
break;
case 1:
tag1values[0] = "Ford";
tag2values[0] = "Prefect";
break;
default:
tag1values[0] = "Zaphod";
tag2values[0] = "Beeblebrox";
break;
}
TIFFField field1 = new TIFFField(tag1, TIFFTag.TIFF_ASCII, tag1values.length, tag1values);
dir.addTIFFField(field1);
TIFFField field2 = new TIFFField(tag2, TIFFTag.TIFF_ASCII, tag2values.length, tag2values);
dir.addTIFFField(field2);
ImageWriteParam iwparam = imageWriter.getDefaultWriteParam();
IIOImage img = new IIOImage(image, null, imageMetaData);
if(j == imageCount - 1) {
imageWriter.write(img);
} else {
if(imageWriter.canInsertImage(0)) {
imageWriter.writeInsert(0, img, iwparam);
}
}
}
iis.close();
fis.close();
fos.flush();
fos.close();
imageWriter.dispose();
}
}
|
|
|
|
|
You need to provide more information about exactly where the error lies, what information should be written to the file and what is being written.
|
|
|
|
|
Thanks for your response. As I said, there is no exception thrown in the code ("runs w/o error"). The problem is that the custom metadata isn't being written to the destination file (output.TIF). In the example above that would be the FirstName and LastName ("Arthur Dent", "Ford Prefect", "Zaphod Beeblebrox"). Sorry I wasn't more explicit.
|
|
|
|
|
Sorry, but you really need to provide more than that. I can only assume there is either a bug somewhere in your code, or an incompatibility with a library. The only way to narrow it down is to do some debugging.
|
|
|
|
|
This is resolved. I was missing a library or had the wrong version.
|
|
|
|
|
import java.util.Scanner;
public class BasicEnglishGrammer1 {
public static Scanner userInputScanner;
public static void main (String args []) {
userInputScanner = new Scanner(System.in);
String userInput = new String (" ");
String name = new String (" ");
System.out.println("\n");
String names [] = {"The", "boy","went","to","the","store"};
System.out.println("Hello, what is your name?");
name =userInputScanner.nextLine();
System.out.println(name + ", can you tell me what the nouns are in the sentence: ");
System.out.println("");
System.out.println("The boy went to the store.");
for(int i=0; i <names.length; i++){
names[i]=userInputScanner.nextLine();
if (names[i].equals("boy") || names[i].equals("store")){
System.out.println("You are right, " + name +" the two nouns are " + names[1] + " and " + names[5] +".");
}
else{
System.out.println("No, " +name + ", that is not correct.");
}
break;
}
System.out.println("");
System.out.println(name + " ,find the nouns in this sentence: ");
System.out.println("The airplane landed at the airport in New Jersey.");
userInput = userInputScanner.nextLine();
if (userInput.equals ("airplane")){
System.out.print("Great job "+ name + " there are two more nouns, can you find them?");
System.out.println("");
userInput= userInputScanner.nextLine();
if (userInput.equals("airport")) {
System.out.println("Great job, can you find one more?");
userInput= userInputScanner.nextLine();
}
if (userInput.equals("New Jersey")){
System.out.println("Excellent Job! "+ name +" do you know that 'New Jersey' is also a 'proper noun'?");
System.out.println("Remember that a 'proper noun' is the NAME of the person, place or thing.");
}
}
}
}
|
|
|
|
|
You should probably start by creating some lists, or arrays, or even a new class, that contain entries for each sentence, and its associated keywords, that you wish to display. Each entry should contain the sentence and the nouns, something like:
{
{ "The boy went to the store", "boy", "store" },
{ "The yacht sailed the ocean", "yacht", "ocean" }
};
You can then loop through your list (or select entries at random) and post the question, and compare responses to the set of nouns following each sentence. You can then add more entries with greater levels of complexity with only minor modifications to your actual executable code.
|
|
|
|
|
how to get auto print jasper report in java
thankyou
|
|
|
|
|
What does the "auto" part mean?
If you mean a scheduled report, one that runs every day, for example, at a certain time then you find a scheduler library. And that has nothing to do with the report itself. However it does mean that something (like a service) must be running all the time so that when the appointed time arrives it can detect the time.
|
|
|
|
|
no no.'auto' mean, I want print a report after only click enter button.think about point of sale(POS) system.cashier can print receipt without select printer.I mean how to set my jasper report like that.
|
|
|
|
|
|
how can i change access specifier of actionperformed from private to public in netbeans
|
|
|
|
|
Type the word "public" in front of it.
|
|
|
|
|
which datatype is best in amount(money)java?
which datatype is best in amount(money)MYSQL?
|
|
|
|
|
float or double depend on the range of money
|
|
|
|
|
No, you should never use floating point types for money.
|
|
|
|
|
|
how to improve update in java servlet in easy type.........
|
|
|
|
|
I need to improve performace, which is implementing Multi-Threading.
My problem is:
1. future.get(); is taking too much time.
2. executor.shutdown(); also taking much time.
Below is my piece of code code we are using below code:
Map<String, List<? extends Object>> entirelist = null;
ExecutorService executor = Executors.newFixedThreadPool(maxThread);
entirelist = manageCJObject.populateCS(cJGroup, load
future = executor.submit(new CsThread(clDAO, entirelist, isUpdate, dbList));
try {
if (future != null) {
long startTime = Calendar.getInstance().getTimeInMillis();
String result = future.get();
System.out.println("Total Time in future.get "+ (Calendar.getInstance().getTimeInMillis()-startTime));
}
long startTime1 = Calendar.getInstance().getTimeInMillis();
executor.shutdown();
executor.awaitTermination(
Constants.INT_VALUE_THIRTY,
TimeUnit.MINUTES);
System.out.println("Total Time in exec shutdown "+ (Calendar.getInstance().getTimeInMillis()-startTime1));
}
catch (ExecutionException execp) {
logger.error("Error dering Thread execution :: " + execp.getMessage());
throw new CLException(execp.getMessage());
}
Kindly let me know how to improve performance. And what way we can provide any alternate of future.get() and executor.shutdown()
|
|
|
|
|
Hi
In short to improve future.get() time you need to improve
your submitted task code i.e. CsThread
Future documentation
as for shutdown(), the function is not blocking so search for submitted task into a pool that take long time to complete.
Good luck
|
|
|
|
|
how to generate cristal report in java ?
|
|
|
|
|
plz give me decryption code for following progrm.....
import java.io.*;
import java.util.Scanner;
import java.util.Random;
import java.lang.Math.*;
class Diffie_Hellman{
public static void main(String[] args) {
Random rand = new Random();
Scanner in = new Scanner(System.in);
System.out.println("Enter any prime number");
int n = in.nextInt();
int g1, g2;
int pb1,pb2,pa1,pa2;
int e1, e2;
int i;
int bk1, bk2, ak1, ak2;
System.out.println("Enter valu of g");
g1= in.nextInt();
g2= in.nextInt();
System.out.println("Enter valu of e");
e1= in.nextInt();
e2= in.nextInt();
int na = rand.nextInt(5)+2;
if(na%2!=0)
na=na+1;
int nb = rand.nextInt(5)+2;
if(nb%2!=0)
nb=nb+1;
System.out.println("Private key of Alice: "+ na + " \n Private key Bob " +nb + " ");
//int pa = (na * g)
// int pb = (nb * g)
int p = na/2;
int g11= g1;
int g22= g2;
for(i=1; i<= p ; i++)
{
double m1=(3*g11*g11+ e1);
double m2= 2*g22;
double inverse=0;
inverse = (Math.pow(m2,-1))%n;
double m =(na*(m1*inverse))%n;
double x = (m*m +(n-(2*g11)))%n;
double y= (m*(x+(n-g11))+g22)%n;
g11=(int)x;
g22=(int)y;
}
if(na%2 == 0)
{
pa1=g11;
pa2=g22;
System.out.println("Alice's Public key is :" +pa1+ " " +pa2 );
}
else
{
double m = (g2-g22)/(g1-g11);
double x3 = (m*m+(n-g1)+(n-g11))%n;
double y3 = (m*(x3+(n-g11)) + g22)%n;
pa1= g11+(int)x3;
pa2= g22+(int)y3;
System.out.println("Alice's Public key is :" +pa1+ " " +pa2 );
}
p = nb/2;
g11= g1;
g22= g2;
for(i=1; i<= p ; i++)
{
double m1=(3*g11*g11+ e1);
double m2= 2*g22;
double inverse=0;
inverse = (Math.pow(m2,-1))%n;
double m =(na*(m1*inverse))%n;
double x = (m*m +(n-(2*g11)))%n;
double y= (m*(x+(n-g11))+g22)%n;
g11=(int)x;
g22=(int)y;
}
if(nb%2 == 0)
{
pb1=g11;
pb2=g22;
System.out.println("Bob's Public key is :" +pb1+ " " +pb2 );
}
else
{
double m = (g2-g22)/(g1-g11);
double x3 = (m*m+(n-g1)+(n-g11))%n;
double y3 = (m*(x3+(n-g11)) + g22)%n;
pb1= g11+(int)x3;
pb2= g22+(int)y3;
System.out.println("Bob's Public key is :" +pb1+ " " +pb2 );
}
System.out.println("******Generating shared key for Alice *******");
p = na/2;
g11= pb1;
g22= pb2;
for(i=1; i<= p ; i++)
{
double m1=(3*g11*g11+ e1);
double m2= 2*g22;
double inverse=0;
inverse = (Math.pow(m2,-1))%n;
double m =(na*(m1*inverse))%n;
double x = (m*m +(n-(2*g11)))%n;
double y= (m*(x+(n-g11))+g22)%n;
g11=(int)x;
g22=(int)y;
}
if(na%2 == 0)
{
ak1=g11;
ak2=g22;
System.out.println("Alice's shared key is :" +ak1+ " " +ak2 );
}
else
{
double m = (g2-g22)/(g1-g11);
double x3 = (m*m+(n-g1)+(n-g11))%n;
double y3 = (m*(x3+(n-g11)) + g22)%n;
ak1= g11+(int)x3;
ak2= g22+(int)y3;
System.out.println("Alice's shared key is :" +ak1+ " " +ak2 );
}
System.out.println("*****Generation of shared key for Bob*****");
p = nb/2;
g11= pa1;
g22= pa2;
for(i=1; i<= p ; i++)
{
double m1=(3*g11*g11+ e1);
double m2= 2*g22;
double inverse=0;
inverse = (Math.pow(m2,-1))%n;
double m =(na*(m1*inverse))%n;
double x = (m*m +(n-(2*g11)))%n;
double y= (m*(x+(n-g11))+g22)%n;
g11=(int)x;
g22=(int)y;
}
if(nb%2 == 0)
{
bk1=g11;
bk2=g22;
System.out.println("Bob's shared key is :" +bk1+ " " +bk2 );
}
else
{
double m = (g2-g22)/(g1-g11);
double x3 = (m*m+(n-g1)+(n-g11))%n;
double y3 = (m*(x3+(n-g11)) + g22)%n;
bk1= g11+(int)x3;
bk2= g22+(int)y3;
System.out.println("Bob's shared key is :" +bk1+ " " +bk2 );
}
System.out.println("Enter Your Messgae");
int msg1 = in.nextInt();
int msg2= in.nextInt();
int k= (bk1*bk2)%n;
System.out.println("Value of K is : " +k);
p = k/2;
if(p<0)
p=p*(-1);
g11= msg1;
g22= msg2;
for(i=1; i<=p ; i++)
{
double m1=(3*g11*g11+ e1);
double m2= 2*g22;
double inverse=0;
inverse = (Math.pow(m2,-1))%n;
double m =(na*(m1*inverse))%n;
double x = (m*m +(n-(2*g11)))%n;
double y= (m*(x+(n-g11))+g22)%n;
g11=(int)x;
g22=(int)y;
}
if(na%2 == 0)
{
pa1=g11;
pa2=g22;
System.out.println("C :" +pa1+ " " +pa2 );
}
else
{
double m = (g2-g22)/(g1-g11);
double x3 = (m*m+(n-g1)+(n-g11))%n;
double y3 = (m*(x3+(n-g11)) + g22)%n;
int c1= g11+(int)x3;
int c2=g22+(int)y3;
pa1= (int)c1;
pa2= (int)c2;
System.out.println("C:" +pa1+ " " +pa2 );
}
//decryption code
}
}
|
|
|
|
|