Java new bee : Help Java 2D
I want to develop an application which includes functionalities such as 1) Writing on the canvas 2) when the written text /scribble is selected by means of drawing a box around it, a new image is created on an other canvas. The image created or appeared could be from an image library.
Please give me some fundamentals to start with. If a source code provided, I am greatful.
Please help me.
Ale
http://www.java2s.com/ExampleCode/CatalogExampleCode.htm
Similar Messages
-
New Bee, Help File Adapter
Hi ,
I am new to XI , I have a basic question on file adapter.
I have configured a file adapter to pick a file with name abc.txt and delete it. Assumes my total scenario takes 30 min to complete. If i get another file in the source folder after 5 min. Does XI process the second file also parallel. Or does it finish first file and then process the second file?
Regards
Monika DietzHi,
>>>>Or does it finish first file and then process the second file?
the file adapter will pick the file as soon as possible
from the folder but you can set quality of service
EOIO so it will wait until the first one will finish
(and other parameters in the integration eigine
so your flow will be processed by one queue only)
but basically it will be processed in paralel
(with standard config)
reference:
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
Regards,
michal -
I'm new to java and need help please
I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
item # description price(this line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
item# quant price per item total(price per item*quant entered)
also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
I've been working on this for days and it seems like nothing I try works. My major problems are:
1. I have no idea how to read the text file and load those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like text for the output file.
code]
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.Locale;
public class arraySelection
extends JApplet {
//Initialize the applet
private Container getContentPane=null;
public void init() {
String string_item, string_quantity;
String output = "";
String description= "";
int counter= 0;
int itemNumber= 0;
double quantity = 0 ;
double tax_rate=.07;
double total= 0, price= 0;
double tax, subtotal;
double Pretotal= 0;
double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
// create number format for currency in US dollar format
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
//format to have the total with two digits precision
DecimalFormat twoDigits = new DecimalFormat("0.00");
//Jtextarea to display results
JTextArea outputArea = new JTextArea ();
// get applet's content pane
Container container = getContentPane ();
//attach output area to container
container.add(outputArea);
//set the first row of text for the output area
output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
do //begin loop structure obtain input from user
// obtain item number from user
string_item = JOptionPane.showInputDialog(
"Please enter an item number 1, 2, 3, 4, or 5:");
//obtain quantity of each item that user enter
string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
// convert numbers from type String to Integer or Double
itemNumber = Integer.parseInt(string_item);
quantity = Double.parseDouble(string_quantity);
switch (itemNumber) {//Determine input from user to assign price and description
case 10: // user input item =10
price = priceArray[0];
description = descriptionArray[0];
break;
case 20: // user input item =20
price = priceArray [1];
description = descriptionArray[1];
break;
case 30: //user input item =30
price=priceArray[2];
description = descriptionArray[2];
break;
case 40: //user input item =40
price=priceArray[3];
description = descriptionArray[3];
break;
case 50: //user input item =50
price=priceArray[4];
description = descriptionArray[4];
break;
default: // user input item is not on the list
output += "Invalid value entered"+ "\n";
price=0;
description= "";
//Calculates the total for each item number and stores it in subtotal
subtotal = price * quantity;
//display input from user
output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
//accumulates the overall subtotal for all items
Pretotal = Pretotal + subtotal;
//verifies that the user wants to stop entering data
string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
itemNumber = Integer.parseInt(string_item);
// loop termination condition if user's input is 0 .It will end the loop
} while ( itemNumber!= 0);
tax = Pretotal * tax_rate; // calculate tax amount
total = Pretotal + tax; //calculate total = subtotal + tax
//appends data regarding the subtotal, tax, and total to the output area
output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
"\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
"\t\t" + moneyFormat.format( total );
//attaches the data in the output variable to the output area
outputArea.setText( output );
} //end init
}// end applet Invoice
Any help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.item # description price(this
line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file
into arrays(I have no clue how to use
multi-dimensional arrays in java and would prefer not
to)That's good, because you shouldn't use multidimensional arrays here. You should have a one-dimensional array (or java.util.List) of objects that encapsulate each line.
I've been working on this for days and it seems like
nothing I try works. My major problems are:
1. I have no idea how to read the text file and load
those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like
text for the output file.The java.io package has file reading/writing classes.
Here's a tutorial:
http://java.sun.com/docs/books/tutorial/essential/io/index.html -
I'm new to java and need help please(repost)
I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
item # description price(this line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
item# quant price per item total(price per item*quant entered)
also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
I've been working on this for days and it seems like nothing I try works. My major problems are:
1. I have no idea how to read the text file and load those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like text for the output file.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.Locale;
public class arraySelection
extends JApplet {
//Initialize the applet
private Container getContentPane=null;
public void init() {
String string_item, string_quantity;
String output = "";
String description= "";
int counter= 0;
int itemNumber= 0;
double quantity = 0 ;
double tax_rate=.07;
double total= 0, price= 0;
double tax, subtotal;
double Pretotal= 0;
double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
// create number format for currency in US dollar format
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
//format to have the total with two digits precision
DecimalFormat twoDigits = new DecimalFormat("0.00");
//Jtextarea to display results
JTextArea outputArea = new JTextArea ();
// get applet's content pane
Container container = getContentPane ();
//attach output area to container
container.add(outputArea);
//set the first row of text for the output area
output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
do //begin loop structure obtain input from user
// obtain item number from user
string_item = JOptionPane.showInputDialog(
"Please enter an item number 1, 2, 3, 4, or 5:");
//obtain quantity of each item that user enter
string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
// convert numbers from type String to Integer or Double
itemNumber = Integer.parseInt(string_item);
quantity = Double.parseDouble(string_quantity);
switch (itemNumber) {//Determine input from user to assign price and description
case 10: // user input item =10
price = priceArray[0];
description = descriptionArray[0];
break;
case 20: // user input item =20
price = priceArray [1];
description = descriptionArray[1];
break;
case 30: //user input item =30
price=priceArray[2];
description = descriptionArray[2];
break;
case 40: //user input item =40
price=priceArray[3];
description = descriptionArray[3];
break;
case 50: //user input item =50
price=priceArray[4];
description = descriptionArray[4];
break;
default: // user input item is not on the list
output += "Invalid value entered"+ "\n";
price=0;
description= "";
//Calculates the total for each item number and stores it in subtotal
subtotal = price * quantity;
//display input from user
output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
//accumulates the overall subtotal for all items
Pretotal = Pretotal + subtotal;
//verifies that the user wants to stop entering data
string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
itemNumber = Integer.parseInt(string_item);
// loop termination condition if user's input is 0 .It will end the loop
} while ( itemNumber!= 0);
tax = Pretotal * tax_rate; // calculate tax amount
total = Pretotal + tax; //calculate total = subtotal + tax
//appends data regarding the subtotal, tax, and total to the output area
output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
"\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
"\t\t" + moneyFormat.format( total );
//attaches the data in the output variable to the output area
outputArea.setText( output );
} //end init
}// end applet InvoiceAny help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.First answer: You shouldn't ask multiple questions in the same thread. Ask a specific question, with an appropriate subject line (optionally, assign the number of Dukes you are willing to give for the help). When question #1 is answered and question #2 arises, it's time for a new thread (don't forget to give out Dukes before moving on).
Second answer: I think you need a Transfer Object (http://java.sun.com/blueprints/patterns/TransferObject.html). It's whole purpose is to hold/transfer instance data where it is needed. Create a class something like this:
public class ItemTO
private String _number;
private String _description;
private double _price;
public ItemTO( String number, String description, double price )
_number = number;
_description = description;
_price = price
// Getter/Setter methods go here
}then, in the code where you read in the file do something like this:
BufferedReader input = null;
try
input = new BufferedReader( new FileReader( "c:\\a.txt" ) );
List items = new ArrayList();
String line;
String itemNumber;
String itemDescription;
double itemPrice;
while ( (line = input.readLine() ) != null )
System.out.println( line );
itemNumber = // Parse it from line
itemDescription // Parse it from line
itemPrice = // Parse it from line
items.add( new ItemTO( itemNumber, itemDescription, itemPrice ) );
catch ( FileNotFoundException fnfe )
fnfe.printStackTrace();
catch ( IOException ioe )
ioe.printStackTrace();
finally
try
if ( input != null )
input.close();
catch ( Exception e )
e.printStackTrace();
}As for how to parse the line of the file, I'll leave that to you for now. Are the three values delimited with any special characters?
jbisotti -
New bee - accessing CIS from java
Hi ,
On the same line. I want to access the CIS from Java. Can you guide me on how I can implement this . Both from a standalone java program and from a web layer ?
I have installed content server 10gR3. I want to acess this server from Java.
Any help is appreciated.I think that if you create a interface in java and a class in javafx that implements that interface you can then pass that class to java. For instance:
Java:
public interface EventReceiver {
public void receive(String event);
// Then your java class that generates the events
public class EventGenerator {
private List<EventReceiver> receivers = new LinkedList<EventReceiver>();
public void registerEventReceiver(EventReceiver er) {
receiver.add(er);
public void unregisterEventReceiver(EventReceiver er) {
receiver.remove(er);
* Add code that calls EventReceiver.receive(String) method for each element in the receiver list
* when the panel is touched.
}and in the JavaFX code:
public class JavaFXEventReceiver extends EventReceiver {
public override function receive(String event) {
// Do UI updates...
}A little more indepth version can be found here:
http://www.compare-review-information.com/pure-java-code-to-call-javafx-class/
You might run into some problems though pertaining to threading...but there are workarounds for that aswell :)
- Emil H -
New JAVA Update = Broken; HELP PLEASE
Yesterday I was alerted to a new update for Java. I installed it and now JAVA doesn't work on this site I always use for work. Is this happening to anyone else? Any ideas on how to fix? Help please. Thanks.
Yesterday I was alerted to a new update for Java. I installed it and now JAVA doesn't work on this site I always use for work. Is this happening to anyone else? Any ideas on how to fix? Help please. Thanks.
-
Im a Total new Person to java plz help...
I was wondering if somone could help me with this code ive been working on...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MadLibGUI
private int WIDTH = 700;
private int HEIGHT = 600;
private JFrame frame;
private JPanel panel;
private JLabel sticker,spray;
private JTextField joe,pizza;
private JTextArea finish;
private JButton done;
// Sets up the GUI.
public MadLibGUI()
frame = new JFrame ("Mad Lib Graphical User Interface");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
sticker = new JLabel ("Enter your first Name:"); // These will be altered as you add new questions
joe = new JTextField (15);
spray = new JLabel ("What's your favorite Food?");
pizza = new JTextField (20);
((((label3 = new JLabel ("Awnser y/n");))))))))
((((((((((((((label4 = new JTextField (25);)))))
done = new JButton("Click when done.");
done.addActionListener (new DoneListener());
finish = new JTextArea(10,60);
finish.setLineWrap(true);
panel = new JPanel();
panel.setPreferredSize (new Dimension(WIDTH, HEIGHT));
panel.setBackground (Color.white);
panel.add (sticker); // These have to be altered as you add new questions
panel.add (joe);
panel.add (spray);
panel.add (pizza);
panel.add (finish);
((((((((((((((((( panel.add (label4);))))))))))))))))))))
frame.getContentPane().add (BorderLayout.SOUTH,done);
frame.getContentPane().add (panel);
// Displays the primary application frame.
public void display()
frame.pack();
frame.show();
// Represents an action listener for the done button.
class DoneListener implements ActionListener
// Performs the conversion when the enter key is pressed in
// the text field and displays the result.
public void actionPerformed (ActionEvent event)
String text1 = joe.getText(); // These will be altered to get the actual input and
String text2 = pizza.getText();
finish.append("Sup "+text1+". I hate That why do you like "+text2+" anyway...HMMM>???!!!!"); // to give the actual output.
(i keep getting this error)
\\w2knas2\data$\Secondary\Users\H\HURLECHR000\QB\MadLibGUI.java:35: cannot resolve symbol
symbol : variable label3
location: class MadLibGUI
label3 = new JLabel ("Awnser y/n");
^
\\w2knas2\data$\Secondary\Users\H\HURLECHR000\QB\MadLibGUI.java:36: cannot resolve symbol
symbol : variable label4
location: class MadLibGUI
label4 = new JTextField (25);
^
\\w2knas2\data$\Secondary\Users\H\HURLECHR000\QB\MadLibGUI.java:52: cannot resolve symbol
symbol : variable label3
location: class MadLibGUI
panel.add (label3);
^
3 errors
Tool completed with exit code 1
(i know its probly a simple change but im stumped...If this is the wrong Section PLZ redirect me to the appropriate place...Thanks ^_^Ohh man I cant believe i did forgot this...Sorry to
Bother you all
private JLabel sticker,spray,
private JTextField joe,pizza,
man i forgot to declare...You are all right im sorry
to bother...but thanks for forcing me to review my
code...No problem.
However, in the future, when you post code, please use [code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read. -
Can get this Servlet to Work! New Java User needs help.
I have been using a text from New Riders to learn about creating server applications, and am using Tomcat as the server in a Windows XP environement. As per the instructions, to create a new application and path, I added the following path under the webapps directory, that sits under my Tomcat directory:
myApps
--WEB-INF
----classes
I then create copied Java class code, listing below, and compiled, put the class in the classes directory in my new directory path. The code is simple, here it is:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Welcome to the Servlet Testing Center");
out.println("</BODY>");
out.println("</HTML>");
I then created a file called web.xml in the WEB-INF directory, as w follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>Testing</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
</web-app>
I started the Tomcat server process, and pointed my browser to the URL http://localhost:8080/myApp/Servlet/TestingServlet. I received the following error
type Status report
message /myApp/Servlet/Testing
description The requested resource (/myApp/Servlet/Testing) is not available.
After searching some information on the web, I found some references to context information, that should be included in another file, called server.xml, that resides under the conf directory in the Tomcat root. I found it, and added the following within the "host" tags, just after the last ending /context tag, for the example directory that came with Tomcat:
<Context path="/myApp" docBase="myApp" debug="0" reloadable="true" >
</Context>
I stopped and restarted the Tomcat server. This time, I checked under the Manager page of Tomcat, and found the myApp directory listed, and apparently "started", whatever that means
pointed my browser to the URL http://localhost:8080/myApp/Servlet/TestingServlet. I still receive the following:
type Status report
message /myApp/Servlet/Testing
description The requested resource (/myApp/Servlet/Testing) is not available.
I tried one more thing. I put my class under the "examples" directory that comes with Tomcat, change the web.xml file that resides under its WEB-INF directory, and tried to see if I can get the servlet to work. And it actually does, which leads me to believe, I did something wrong setting up the directory environment in Tomcat.
At this point I am at a loss to figure out what I did wrong, and what else I can do to fix this. Any help, suggestions, would be great.ok, I have got your servlet runnig on Jboss with Tomcat,
The war file contents are
myApp/
META-INF/
META-INF/MANIFEST.MF
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/TestingServlet.class (No package)
WEB-INF/web.xml
Web.xml
<web-app>
<servlet>
<servlet-name>Testing</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Testing</servlet-name> <------- My mistake use Testing
<url-pattern>/servlet/testing/*</url-pattern <------- lowercase S
</servlet-mapping>
</web-app>
url
http://localhost:8080/myApp/testing/blah -
I am new to java and need help to
how can i read a class-file
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Capitalizeapplet extends Applet {
private TextField input;
private TextField output;
public void init() {
input = new TextField(40);
output = new TextField(40);
output.setEditable(true);
Button b= new Button("Capitalize");
this.add(input);
this.add(b);
this.add(output);
CapitalizerAction ca=new CapitalizerAction(input,output);
b.addActionListener(ca);
this.input.addActionListener(ca);
class CapitalizerAction implements ActionListener
private TextField in;
private TextField out;
public CapitalizerAction(TextField in,TextField out)
this.in=in;
this.out=out;
public void actionPerformed(ActionEvent ae)
String s=in.getText();
out.setText(s.toUpperCase());
at any time man, we are in service
(it's my first time to answer someone, coz I'm biggener exactly like u!...but I took that lesson ;) -
File Encryption: New to Java encryption plz help
ive been looking at some code i got from a friends java book about how to encode/decode stuff. It seems to me that the key that is generated would be a one time thing and you would get a new one the next time you tried. If that happened i would think at least you would not decode the text correctly that had previosly been encoded by a different key. Plz point out another example for what im trying to do if this one is doing something else which it seems to me it must be. Or if not plz explain how it works. Thanks for youre time.
heres the code ive been looking at to learn how to encode/decode files for a game ive been working on:
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.awt.*;
import java.util.*;
public class TestCipher{
public static void main(String args[]) throws Exception {
Set set = new HashSet();
System.out.println("Enter password\nMust contain at least 8 characters");
BufferedReader first = new BufferedReader(new
InputStreamReader(System.in));
//password must be at leaste 8 charaacters
//private static final
String password = "uuuuuuuu";
password = first.readLine();
Random random = new Random();
for (int i=0; i<10; i++){
Point point = new Point(random.nextInt(1000), random.nextInt(2000));
set.add(point);
int last = random.nextInt(5000);
//create key
byte key[] = password.getBytes();
DESKeySpec desKeySpec = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
//create Cipher
Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
desCipher.init(Cipher.ENCRYPT_MODE, secretKey);
//create Stream
FileOutputStream fos = new FileOutputStream("out.des");
BufferedOutputStream bos = new BufferedOutputStream(fos);
CipherOutputStream cos = new CipherOutputStream(bos, desCipher);
ObjectOutputStream oos = new ObjectOutputStream(cos);
//write objects
oos.writeObject(set);
oos.writeInt(last);
oos.flush();
oos.close();
//change Cipher Mode
desCipher.init(Cipher.DECRYPT_MODE, secretKey);
//Create Stream
FileInputStream fis = new FileInputStream("out.des");
BufferedInputStream bis = new BufferedInputStream(fis);
CipherInputStream cis = new CipherInputStream(bis, desCipher);
ObjectInputStream ois = new ObjectInputStream(cis);
//read objects
Set set2 = (Set)ois.readObject();
int last2 = ois.readInt();
ois.close();
//compare original with what is read back
int count = 0;
if (set.equals(set2)){
System.out.println("Set1:" + set);
System.out.println("Set2:" + set2);
System.out.println("Sets are okay.");
count++;
if (last == last2){
System.out.println("int1:" + last);
System.out.println("int2:" + last2);
System.out.println("ints are okay.");
count++;
if (count != 2){
System.out.println("Problem during encryption/decryption");You can use EnvelopedDataGenerator from BC library.
FileInputStream src = new FileInputStream(inputFile); // File to encrypt
byte[] data = new byte[src.available()];
src.read(data);
src.close();
CMSEnvelopedDataGenerator dataGenerator =new CMSEnvelopedDataGenerator();
dataGenerator.addKeyTransRecipient(getPersonalCertificate()); // add personal certificate
// OPTIONAL add other recipients certificates who can decode
dataGenerator.addKeyTransRecipient(cert1);
CMSProcessableByteArray byteArray =new CMSProcessableByteArray(data);
CMSEnvelopedData envelopedData = dataGenerator.generate(byteArray, CMSEnvelopedDataGenerator.DES_EDE3_CBC, "BC");
FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(envelopedData.getEncoded());
fos.close(); -
Hi all
I'm new bee into this Java connectivity with SAP. I have good experience in developing J2EE applications and right now concentrating on using J2EE in SAP. I started learning ABAP and did not understand upto what level should I do expertise in it. I'm not sure whether learning ABAP would help me or not. Please advice me where to start and good self learning resources. I heard we can use ABAP in JSP pages. I'm totally confused for a good start.
~SashiSashi,
OK. Well our approach appears to be somewhat different than the general approach taken by the members of this forum in that we use WebSphere and WSAD to develop, not the environment preferred by SAP. In our architecture (BTW, we are religiously J2EE), we have chosen Java Server Faces for our front end and we use the JCA architecture to connect to SAP. We started with proof of concepts using JCA ( you can get the files from SAP web site ). In these proof of concepts we looked at how to manage transactions, simplicity of API, and performance. In transaction management, you can use different approaches: You can manually manage them with calls via JCA, or integrate them into the EJB framework - letting the container commit your calls. Just a note: Jco is currently the most widely used method of connecting java apps to SAP. We did not choose this approach for two reasons: It is not a J2EE API and it uses JNI.
We also looked at WebServices as way to connect to SAP, but we are not sure how to call different web services all inside the same transaction, so we will not go with this approach (we have no more time to investigate).
Also, another way of connecting to SAP is with XI. We were not accepted for ramp up for this product, so unfortunately we cannot look into this approach for our current project, but this approach appears to be one in which SAP will be investing much effort.
Hope this helps some !
Mark -
How to read the content in one node of XML in Java? Pls help
My dear brothers,
I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
1. Create a GUI form which gives the ability for user to choose a XML file (ok)
2. Load XML and return the file (ok)
3. Read the file from node to node to create the node in Tree View (?!)
Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
Hoang Yen BinhI hope this one helps you.
<ABC Type="ProductBased" ProdName="One" Location="India">
<CEO>Raj</CEO>
<Finance>Vikram</Finance>
<HR>Karthik</HR>
<Technical>Satish</Technical>
</ABC>
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
public class XmlReading {
Document doc;
Element element;
public static void main(String[] args) throws Exception{
XmlReading xr = new XmlReading();
xr.getXmlParser(args);
public void getXmlParser(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
if(args.length != 1) {
System.err.println("Argument Required");
try {
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(new File(args[0]));
}catch(ParserConfigurationException e1) {
}catch(SAXException e2) {
}catch(IOException e3) {
getAttributes();
public void getAttributes() {
// Retrive the entire Document from the Dom Tree
element = doc.getDocumentElement();
// System.out.println(element);
NamedNodeMap attrs = element.getAttributes();
// Get number of attributes in the element
int numAttrs = attrs.getLength();
// Process each attribute
for (int i=0; i<numAttrs; i++) {
Node node = attrs.item(i);
// Get attribute name and value
String attrName = node.getNodeName();
String attrValue = node.getNodeValue();
System.out.println(attrName + ": " + attrValue);
String s1 = element.getTagName();
System.out.println(s1);
// To get all the elements in a DOM Tree
NodeList nl1 = element.getElementsByTagName("*");
int i2 = nl1.getLength();
System.out.println(i2);
for(int i=0; i<i2; i++) {
System.out.println(nl1.item(i) + "\n");
} -
Please I am doing my final year project on secure mobile application using Java Card Technology.
I need to write and an application that can send SMS on a SIM card to another SIM card with the same application. The application will have a server side which manage the storage of messages and at the same time communicate information to the client on the SIM remotely. I am suppose to use wi-fi (TCP/IP) for transmission.
Can anybody please give me ideas and possible working codes and simulators.
I mean step by step procedure of how to start.
THANK YOU.Hi,
I found the following resources helpful when starting out in JavaCard.
JavaCard documentation:
Java Card Technology for Smart Cards: Architecture and Programmer's Guide (Book)
http://java.sun.com/docs/books/javacard/index.html
JavaCard specifications:
http://java.sun.com/products/javacard/specs.html
Global Platform specifications:
http://www.globalplatform.org/specificationview.asp?id=card
Communication between SmartCards and terminals is based on ISO 7816 part 3 and 4 so if you�re completely new to the SmartCard environment it may be helpful getting an overview regarding these specifications. Unfortunately these specifications are not free, they�re available from.
http://www.iso.org/iso/en/ISOOnline.frontpage
Software:
The basis for all development is the JavaCard and Java Development kits.
Java Development Kit
http://java.sun.com/j2se/1.4.2/download.html
JavaCard Development Kit
http://java.sun.com/products/javacard/dev_kit.html
Full installation instructions can be found in JCDevKit_User_Guide.pdf which is contained in the JavaCard Development Kit distribution.
Several companies provide IDE�s that will aid you in developing and deploying applets to JavaCard.
For example:
Aspects Developer
http://www.aspectssoftware.com/devtools/index.html
There are others out there as well. You may need to also buy physical sample cards; however, the IDE�s usually have simulators built in.
Hardware:
To interact with physical cards you�ll require a PCSC compatible card reader.
Omnikey
http://www.omnikey.com/
GemPlus
http://support.gemplus.com/gemdownload/readers/index.aspx
Hope this helps.
Cheers,
Alasdair -
Methods & Switch Statement in java.. HELP!!
hi all...
i am having a slight problem as i am constructing a method --> menu() which handles displaying
menu options on the screen, prompting the user to select A, B, C, D, S or Q... and then returns the user
input to the main method!!!
i am having issues with switch statement which processes the return from menu() methd,,,
could you please help?!!
here is my code...
import java.text.*;
import java.io.*;
public class StudentDriver
public static void main(String[] args) throws IOException
for(;;)
/* Switch statement for menu manipulation */
switch(menu())
case A: System.out.println("You have selected option A");
break;
case B: System.out.println("You have selected option B");
break;
case C: System.out.println("You have selected option C");
break;
case D: System.out.println("You have selected option D");
break;
case S: System.out.println("You have selected option S");
break;
case Q: System.out.println("\n\n\n\n\n\n\t\t Thank you for using our system..." +
"\n\n\t\t\t Good Bye \n\n\n\n");
exit(0);
static char menu()
char option;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("\n\n");
System.out.println("\n\t\t_________________________");
System.out.println("\t\t| |");
System.out.println("\t\t| Student Manager Menu |");
System.out.println("\t\t|_______________________|");
System.out.println("\n\t________________________________________");
System.out.println("\t| \t\t\t\t\t|");
System.out.println("\t| Add new student\t\t A \t|");
System.out.println("\t| Add credits\t\t\t B \t|");
System.out.println("\t| Display one record\t\t C \t|");
System.out.println("\t| Show the average credits\t D \t|");
System.out.println("\t| \t\t\t\t\t|");
System.out.println("\t| Save the changes\t\t S \t|");
System.out.println("\t| Quit\t\t\t\t Q \t|");
System.out.println("\t|_______________________________________|\n");
System.out.print("\t Your Choice: ");
option = stdin.readLine();
return option;
}Thanking your help in advance...
yours...
khalidHi,
There are few changes which u need to make for making ur code work.
1) In main method, in switch case change case A: to case 'A':
Characters should be represented in single quotes.
2) in case 'Q' change exit(0) to System.exit(0);
3) The method static char menu() { should be changed to static char menu() throws IOException {
4) Change option = stdin.readLine(); to
option = (char)stdin.read();
Then compile and run ur code. This will work.
Or else just copy the below code
import java.text.*;
import java.io.*;
public class StudentDriver{
public static void main(String[] args) throws IOException {
for(;;) {
/* Switch statement for menu manipulation */
switch(menu()) {
case 'A': System.out.println("You have selected option A");
break;
case 'B': System.out.println("You have selected option B");
break;
case 'C': System.out.println("You have selected option C");
break;
case 'D': System.out.println("You have selected option D");
break;
case 'S': System.out.println("You have selected option S");
break;
case 'Q':
System.out.println("\n\n\n\n\n\n\t\t Thank you for using our system..." +
"\n\n\t\t\t Good Bye \n\n\n\n");
System.exit(0);
static char menu() throws IOException {
char option;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("\n\n");
System.out.println("\n\t\t_________________________");
System.out.println("\t\t| |");
System.out.println("\t\t| Student Manager Menu |");
System.out.println("\t\t|_______________________|");
System.out.println("\n\t________________________________________");
System.out.println("\t| \t\t\t\t\t|");
System.out.println("\t| Add new student\t\t A \t|");
System.out.println("\t| Add credits\t\t\t B \t|");
System.out.println("\t| Display one record\t\t C \t|");
System.out.println("\t| Show the average credits\t D \t|");
System.out.println("\t| \t\t\t\t\t|");
System.out.println("\t| Save the changes\t\t S \t|");
System.out.println("\t| Quit\t\t\t\t Q \t|");
System.out.println("\t|_______________________________________|\n");
System.out.print("\t Your Choice: ");
option = (char)stdin.read();
return option;
regards
Karthik -
Image size and mime type.. non-java guy needs help
Image size, mime type.. non-java guy needs help
Im not at all familiar with java so this is really weird for me to work out. I?ve been doing it all day (and half of yesterday).
Im trying to write a custom clodFusion tag in java that gets the width, height, size and MIME types of a given file. I?ve been trying to get it to work on the command line first. I can get the width and height but cant get the size and the MIME type.
Here is what I got
/*import com.allaire.cfx.*;*/
import java.awt.image.renderable.*;
import javax.media.jai.*;
import com.sun.media.jai.codec.*;
import java.io.*;
import java.util.*;
public class ImageInfo {
private RenderedOp image = null;
private RenderedOp result = null;
private int height = 0;
private int width = 0;
private String type = "";
private String size = "";
public void loadf(String file) throws IOException
file = "80by80.jpg";
FileSeekableStream fss = new FileSeekableStream(file);
image = JAI.create("stream", fss);
height = image.getHeight();
width = image.getWidth();
System.out.println(height + "\n");
System.out.println(width);
System.out.println(type);
public static void main(String[] args) throws IOException {
ImageInfo test = new ImageInfo();
test.loadf(args[0]);
can anyone please help me out to modify the above so I can also print the mime type and the file size to screen.
thanks for any helpany suggestions?
Maybe you are looking for
-
Problem with InitialContext Creation in Weblogic 5.1
Hi all, We are using Weblogic 5.1 on Windows and Solaris. We are trying to get InitialContext by the following code snippet. This piece of code is in a Thread which is kicked off by a startup class. The purpose of getting the initialContext here is t
-
I am implementing QM for purchased parts. I wanted to know that what are the master data I need to maintan,what configuration I have to do ,what transaction codes I have to use and what is the QM cycle. ravi
-
Visula admin tool, remote configuration
Hi all , Planned to configure Visual admin tool on local PC for SOLMAN 7.0 with the same network. Note 758298 - Offline Installation of J2EE Engine Visual Administrator Do i need to follow the same note If yes, Im getting stucked in downloading the
-
Hi Experts, I try use NWDI, but, I created a Product and Software Component in SLD, and define my dependencies. After, I created a new track with a SC. This SC has the DC necessaries (JEE, Build and JTechs). Now, when I go to Transport Studio, the C
-
Code correction, please!
Hi, The following code throws an error. Correct it please. myGrid.addEventListener(Event:ListEvent.ITEM_CLICK, gridItemClick); function gridItemClick (e:ListEvent):void{ var urlR:URLRequest=new URLRequest(e.target.getItemAt(e.rowIndex).PDF) navigateT