Showing results for 
Search instead for 
Did you mean: 

How to convert java code to Portal

Former Member
0 Kudos


I have java code which resizes the image. I want to know whether the code would work fine in PDK.if not what is the chanes to be done to the attached code.

import com.sun.image.codec.jpeg.*;

import java.awt.*;

import java.awt.image.*;


public class Thumbnail1


public static void main(String[] args) throws Exception


if (args.length != 4)


System.err.println("Usage: java Thumbnail INFILE " + "OUTFILE WIDTH HEIGHT ");



// load image from INFILE

Image image = Toolkit.getDefaultToolkit().getImage(args[0]);

MediaTracker mediaTracker = new MediaTracker(new Container());

mediaTracker.addImage(image, 0);


// determine thumbnail size from WIDTH and HEIGHT

int newImageWidth = Integer.parseInt(args[2]);

int newImageHeight = Integer.parseInt(args[3]);

double newImageRatio = (double)newImageWidth / (double)newImageHeight;

int oldImageWidth = image.getWidth(null);

int oldImageHeight = image.getHeight(null);

double oldImageRatio = (double)oldImageWidth / (double)oldImageHeight;

if (newImageRatio > oldImageRatio)


newImageWidth = (int)(newImageHeight * oldImageRatio);




newImageHeight = (int)(newImageWidth / oldImageRatio);


// draw original image to thumbnail image object and

// scale it to the new size on-the-fly

BufferedImage newThumbImage = new BufferedImage(newImageWidth, newImageHeight, BufferedImage.TYPE_INT_RGB);

Graphics2D graphics2D =newThumbImage.createGraphics();

graphics2D.drawImage(image, 0, 0, newImageWidth, newImageHeight, null);

// save thumbnail image to OUTFILE

BufferedOutputStream outFile = new BufferedOutputStream(new FileOutputStream(args[1]));

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outFile);

JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(newThumbImage);




System.out.println("Successfully Saved.");




Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi ramalingam,

i dont know how well u can access the java applications from portal. i am sending u the following link just refer that.

but i am very sure u can access j2ee applications. see the following link.

if u find anything regarding access of java applications just inform will be a good learning curve for me.

i think u can display your java class as web services and consume it in portal..



Message was edited by: purushothaman vyasarao

Answers (1)

Answers (1)

Former Member
0 Kudos


i think the problem could be with portalapp.xml, post it so that we can find the error.