JAVA unsteady preformance...
I have a quite complex GA Java Application.
Due to the problem i need to make a lot of copies of objects and thier attributes. So to find out where i lose preformance i added a time output to the methods used.
Unfortunately this preformance measure is very unstable.
I don't use threads right now and the duration for certain methods range from 2ms up to 40ms. This is quite a difference for the very same method used.
Can i improve preformance by using high priority threads !?
Any clue why the preformance is so unsteady?
Hi,
Please refer this URL.
http://www.JavaPerformanceTuning.com/tips.shtml
It will give you a good idea.
Thanks
Bakrudeen
Similar Messages
-
How to access JDBC Resource registered in Sun Java System App Server ?
I want to create a stand-alone JDBC application with Java SE using Swing technologies and JNDI technology. The purpose of using JNDI technology is to avoid change of Java Source Code every time I move the database to different location. This Java application will be used in a standalone PC installed with Windows XP Professional with no LAN / WAN connection. Of course, Internet connection is available with the PC.
I use JavaDB to store the data tables and the location of the database is D:\E-DRIVE\SAPDEV. Tomorrow, if I move this database to C:\SAPDEV or any network drive, I do not want to change the Java Source code. I want to use JNDI which, if I am not wrong, helps developers to avoid manual change of Java source code whenever the database location is changed. Changes have to be made only in the JNDI Name which contains all relevant information about the database in order to get connection no matter where the database SAPDEV is stored; it can be placed under D:\E-DRIVE directory or C:\ directory of the hard disk. To implement my intention, I started developing Java application as per the steps mentioned below:
Step 1:
To proceed, first, I sought the help of Sun Java System Application Server Admin Console. I created JNDI object for Connection Pool using the menu path Common Tasks->Resources->JDBC->Connection Pools.
JNDI Name : ABAPRPY
Resource Type : javax.sql.DataSource
Datasource class : org.apache.derby.jdbc.ClientDataSource
Description : ABAP Program Repository
The Connection Pool creation has options for General, Advanced and Additional Settings tabs and I made all the settings relevant to the database I created in D:\E-DRIVE\SAPDEV.
To confirm whether the above settings are correct, I pressed the Ping push button which is available in the General tab of the connection pool creation screen. The system responded with the message Ping Succeeded.
Step 2:
I created a JDBC Resource using the menu path Common Tasks->Resources->JDBC->JDBC Resources.
JNDI Name : jdbc/SAPDEV
Pool Name : ABAPRPY
Description : Database Connection for SAPDEV database
Status : Enabled
I can see all the above settings recorded in the domain.xml which is placed in the folder
C:\Sun\AppServer\domains\domain1\config
Step 3:
I have made sure that Sun Java System Application Server is up and running in the background with JavaDB server. I created a Java Program making sure the following JAR files are included in the classpath:
appserv-admin.jar
appserv-ee.jar
appserv-rt.jar
javaee.jar
fscontext.jar
Plus, the lib directory of JDK 1.6 & C:\Sun\AppServer\domains\domain1\config
Source code of the program is as follows: I used NetBeans IDE to create my project file.
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.*;
import javax.activation.DataSource;
public class JNDILookup {
public static void main(String[] args) {
try {
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/sapdev>");
} catch (NamingException ex) {
Logger.getLogger(JNDILookup.class.getName()).log(Level.SEVERE, null, ex);
When I attempted to compile the above program in NetBeans IDE ,no compilation error reported. But while executing the program, I got the following run-time error message:
SEVERE: null
javax.naming.NameNotFoundException: No object bound for java:comp/env/jdbc/sapdev> [Root exception is java.lang.NullPointerException]
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:224)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at SAPConnect.JNDILookup.main(JNDILookup.java:21)
Caused by: java.lang.NullPointerException
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
... 3 more
Now, I want to come out of this situation; at the same time, I want to preserve the settings I have made in the Sun Java System Application Server Admin Console. That is, I want to programmatically access the data source using Connection Pool created in Sun Java System Application Server Admin Console.
I request dear forum members to provide me an appropriate solution.
Thanks and regards,
K. Rangarajan.jay44 wrote:
Bare in mind I am attempting the context.lookup() from inside the container (my code is in a session bean). I have accessed the server and have my bean "say hello" first to verify the bean works OK, then I call a method with this rather standard code:
String jndiDataSourceName ="Second_EJB_Module_DataBase";
Logger.getLogger(DynamicPU.class.getName()).log(Level.INFO,"Programatically acquiring JNDI DataDource: "+ jndiDataSourceName);
InitialContext ctx;
try {
ctx = new InitialContext();
ds =(DataSource)ctx.lookup("java:comp/env/jdbc/"+jndiDataSourceName);
} catch (NamingException ex) {
Logger.getLogger(DynamicPU.class.getName()).log(Level.SEVERE, null, ex);
return "Exception generated trying to preform JDBC DataSource lookup. \n"+ex.toString();
But when I run the code the server log shows the initial context is created Ok, but an exception is thrown becasue the resource name is not found:
(and i have tried vriations of ctx.lookup("jdbc/"+jndiDataSourceName) etc etc
You are fine here. It works in container because the InitialContext properties have been supplied already. That was the link I forwarded earlier. The InitialContext you create locally needs to locate the container JNDI. That is what the properties specify.
Where I am confused is where you indicate the stack below is from the server log. So, you initiate a standalone (java main method) application, create an InitialContext, and you see the results in your app server log?
LDR5010: All ejb(s) of [EJB_Module_1] loaded successfully!
Programatically acquiring JNDI DataDource: Second_EJB_Module_DataBase
The log message is null.
javax.naming.NameNotFoundException: Second_EJB_Module_DataBase not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:192)...
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
This is strange since I can see this resource (a JDBC connection named Second_EJB_Module_DataBase) is configured on the server from the server's admin console.
That is why you can obtain a lookup from within the container (app server).
For this lookup to work it may be that one must map the name inside an ejb-jar.xml deployed with the application, but I have also read some resources like jdbc connection should have a default name. Does anyone know if my lookup() should work without using an ejb-jar.xml mfile to explcitly map the reource for my application?
Both EBJ's and data sources can be referenced via JNDI. It's a remote lookup (that is normally optimized if it is running in the same JVM). You should not have any dependencies on a JDBC data source being set-up on ejb-jar.xml. That file can of course impact your EJB's. However, data sources are normally set-up on a container-specific basis (e.g., you probably did it through a console, but there is a spec somewhere about how to set up a data source via a resource the app server looks for; it varies from app server to app server). However, once you have that container-specific data source set-up, JNDI operates vendor-neutral. You should be able to take the code above and move it to JBoss or Weblogic or Tomcat or whatever (this is an ideal, in practice, the vendors sometimes put a data source in a name you would not expect, but again, you can use their JMX console to see what the JNDI name is).
(As I stated above if I have to use a deployment discriptor to get at this JNDI datasource, then solution is not "programmatic" as newly configured datasources could not be accessed without redeploying the entire application).
As JSchell alluded to, you will always have at least something vendor-specific. JNDI itself (the code you wrote) is totally portable. However, you have to set the various JNDI environment properties to a given vendor's spec. Ideally, you should not need a vendor's actual InitialContext application, but it's a possibility. Once you can safely cast to Context, you should be vendor-neutral (if not, demand your money back).
So that is exactly where I am stuck, trying to get the lookup to work and wondering if it should work without and xml file mapping the resource for my app.
What we ended up doing for standalone was to provide our own JNDI. If you look at the open source project JOTM, there are examples on how to use that with XBean (if integrating with Spring, as we did), you can easily set up a data source that runs standalone exactly as you get in the container. Another benefit is you get full JTA/JTS support and the ability to run XA transactions. (This might all be alphabet soup, but the app server gives it to you, and this is the way we ended up doing the same: JNDI + JTA + JTS + XA). It ends up the same application code uses a "vanilla" InitialContext and all we have to do is write one or two xml files (one for our app server, a couple for JOTM), and our actual code works the same.
I still think you have a shot at getting to the container's JNDI, just not using their full-blown app server JAR.
I think there must be a simple way to do this with an ejb-jar.xml, I am no expert in JNDI, I could be missing something simple, I will keep at it and post an answer here if I come up with it.
Thanks, jayIt is simple to code. Getting it to integrate with your app server, yes, that can be challenging. But it has nothing to do with EJB's. Write a simple test. Using nothing but DataSource and InitialContext. Let us know where you get stuck.
- Saish -
How to encrypt jar files ? (please recommand tool to secure java class file
Dear All:
After release of our webstart application,I begin to worry about the source code -anti compiling if jars are extracted by un-knowen user.
Is there any tool to secure specified jars of a webstart application (wich is composed of lot jar files,I just only want to secure the "KEY" jar file)
I also heard that obfuscator hurts performance ,My boss does not allow such solution)
Besides,If I have to use obfuscator,Is there any setting in jnlp to noted?
Regards
john from Taiwan.We're using Klassmaster: http://www.zelix.com/klassmaster/index.html
There are a lot of discussions about de-compiling, encrypting and so on on the web, but enctyption discussions allways end up in a catch-22 case, because you will have to supply the classloader with key to unlock your jar-files....
obfuscation is not perfect either, but it can make it really had to get anything usefull from the de-compiled code. We have not noted any preformance problems with obfuscation, only some reflection issues :-)
There are also some special compilers for java which creates linux / windows executables: http://www.excelsior-usa.com/jet.html but I have not tried this myself...
Message was edited by:
AsbjornAarrestad -
Hi this code for java i am having major problems. I am a newbie to java so please be kind and hope in the feature i can master java and then help to each others. I will include the show GUI class later.
My main problem is how to assign events to the button so that it preforms a calculation.
Second what should make my GUI run properly and what actions do i need to take.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ConvertValues extends JPanel {
public class ConvertValues {
JFrame window;
JComboBox inputcombo,outputcombo;
JRadioButton Length,Mass,Volume,Temperature;
JButton = new JButton("Convert");
JTextField outputtext, inputtext;
public ConvertValues(){
window = new JFrame("Imperial to Metric Converter");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(600,600);
window.setVisible(true);
addRadioButtons();
addComboBox();
public void addPanel(){
Public JPanel getPanel();
JPanel wrapper = new JPanel();
wrapper.setLayout(new BorderLayout());
wrapper.setBorder(BorderFactory.createEmptyBorder(13,13,13,13));
JPanel centre = new JPanel ();
centre.setLayout(new GridLayout(2,2));
public void addRadiobButton(){
JRadioButton RadioButton = new JRadioButton();
JPanel rbut = new JPanel();
rbut1.setLayout(new GridLayout(4,4));
JPanel panel1 = new JPanel();
JLabel metric = new JLabel (" Length Metric Values")
panel1.add(metric);
rbut1.add (panel1);
JPanel panel2 = new JPanel();
JTextField text1 = new JTextField (13);
panel2.add(text1);
rbut1.add(panel2);
JPanel panel3 = new JPanel();
JLabel imperial = new JLabel ("Length Imperial Values")
panel3.add(Imperial);
rbut1.add (panel3);
JPanel panel4 = new JPanel();
JTextField text2 = new JTextField (13);
panel4.add(text2);
rbut1.add(panel4);
JPanel rbut2 = new JPanel();
rbut2.setLayout(new GridLayout (4,4));
JPanel panel5 = new JPanel ();
JLabel metric2 = new JLabel ("Liquid Metric Values");
panel5.add(metric2)
rbut2.add(panel5);
JPanel panel6 = new JPanel ();
JTextField text3 = new JTextField (13);
panel6.add(text3);
rbut2.add(panel6);
JPanel panel7 = new JPanel ();
JLabel imperial2 = new JLabel ("Liquid Imperial Values");
panel5.add(imperial2)
rbut2.add(pane7);
JPanel panel8 = new JPanel ();
JTextField text4 = new JTextField (13);
panel8.add(text4);
rbut2.add(panel8);
JPanel rbut3 = new JPanel();
rbut3.setLayout(new GridLayout (4,4));
JPanel panel9 = new JPanel ();
JLabel metric3 = new JLabel (" Mass Metric Values");
panel9.add(metric3)
rbut3.add(panel9);
JPanel panel10 = new JPanel ();
JTextField text5 = new JTextField (13);
panel10.add(text5);
rbut3.add(panel10);
JPanel panel11 = new JPanel ();
JLabel imperial3 = new JLabel ("Mass Imperial Values");
panel11.add(imperial3)
rbut3.add(pane11);
JPanel panel12 = new JPanel ();
JTextField text6 = new JTextField (13);
panel12.add(text6);
rbut3.add(panel12);
JPanel rbut4 = new JPanel();
rbut4.setLayout(new GridLayout (4,4));
JPanel panel13 = new JPanel ();
JLabel metric4 = new JLabel (" Temperature Metric Values");
panel13.add(metric4)
rbut4.add(panel13);
JPanel panel14 = new JPanel ();
JTextField text6 = new JTextField (13);
panel14.add(text6);
rbut4.add(panel14);
JPanel panel15 = new JPanel ();
JLabel imperial4 = new JLabel ("Temperature Imperial Values");
panel15.add(imperial4)
rbut4.add(pane15);
JPanel panel16 = new JPanel ();
JTextField text7 = new JTextField (13);
panel16.add(text7);
rbut4.add(panel16);
radiopanel.add("Length","rbut1")
radiopanel.add("Liquid Mass","rbut2")
radiopanel.add("Mass","rbut3")
radiopanel.add("Temperature","rbut4")
public void addComboBox(){
JPanel panel17 = new JPanel();
String[] str = {"Milliimeters", "Centimeters", "Meters", "Kilometers"};
JComboBox metricvalues = newJComboBox(str);
panel17.add(metricvalues);
rbut1.add(panel17);
JPanel panel18 = new JPanel();
String[] str2 = {"Inch", "Foot", "Yard", "Mile"};
JComboBox imperialvalues = newJComboBox(str2);
panel18.add(imperialvalues);
rbut1.add(panel18);
JPanel panel19 = new JPanel();
String[] str3 = {"Litres", "Millilitres", "Litres"};
JComboBox metricvalues = newJComboBox(str3);
panel19.add(metricvalues);
rbut2.add(panel19);
JPanel panel20 = new JPanel();
String[] str4 = {"Fluid", "Ounce", "Pint", "Quart", "Gallon"};
JComboBox imperialvalues = newJComboBox(str4);
panel20.add(imperialvalues);
rbut2.add(panel20);
JPanel panel21 = new JPanel();
String[] str5 = {"Grammes", "Kilogrammes", "Metric Tonne"};
JComboBox metricvalues = newJComboBox(str5);
panel21.add(metricvalues);
rbut3.add(panel21);
JPanel panel22 = new JPanel();
String[] str6 = {"Ounce", "Pound", "Stone", "Long Ton"};
JComboBox imperialvalues = newJComboBox(str6);
panel22.add(imperialvalues);
rbut3.add(panel22);
JPanel panel23 = new JPanel();
String[] str6 = {"Grammes", "Kilogrammes", "Metric Tonne"};
JComboBox metricvalues = newJComboBox(str6);
panel23.add(metricvalues);
rbut4.add(panel23);
JPanel panel24 = new JPanel();
String[] str7 = {"Ounce", "Pound", "Stone", "Long Ton"};
JComboBox imperialvalues = newJComboBox(str7);
panel24.add(imperialvalues);
rbut4.add(panel24);
frame.getContentPane().add(center, BorderLayout.CENTER);
public void addLabelandtext();{
inputlabel = new JLabel("Enter Value");
valuelabel = new JLabel("0");
metricLabel = new JLabel ("Metric Value");
imperial value = new JLabel("Imperial Value");
outputtext = new JTextField(8);
inputtext = new JTextField (8);
JPanel labelpanel = new JPanel();
labelpanel.add(inputlabel);
labelpanel.add(mJPanel panel25 = new JPanel();
labelpanel.add(imperiallabel);
labelpanel.add(valuelabel);
labelpanel.add(outputtext);
labelpanel.add(inputtext);
JPanel top = new JPanel(new GridLayout(5,3));
middle.add(labelpanel);
frame.getContentPane().add(middle,BorderLayout.SOUTH);
public void ConvertButton();{
JPanel panel25 = new JPanel();
JButton convert = new JButton ("CONVERT");
Convert.addActionListener(this);
panel25.add(convert);
rbut1.add(panel 25));
JPanel panel26 = new JPanel();
JButton convert = new JButton ("CONVERT");
Convert.addActionListener(this);
panel26.add(convert);
rbut2.add(panel 26));
JPanel panel27 = new JPanel();
JButton convert = new JButton ("CONVERT");
Convert.addActionListener(this);
panel27.add(convert);
rbut3.add(panel 27));
JPanel panel28 = new JPanel();
JButton convert = new JButton ("CONVERT");
Convert.addActionListener(this);
panel28.add(convert);
rbut4.add(panel 28));
public void LengthConverter();{
Let measurement = TextIO.getDouble()
Let units = TextIO.getlnword();
if the units are inches
Let inches = measurement
else if the units are milimeters
Let inches = measurement*25.4
else if the units are Foot
Let centirmeter = measurement*30.48
else if the units are Yard
Let meter = measurement*0.9144
else if the units are mile
let kilometers = measurement*1.609
else if the unit are meters
let centimeters = measurement*100
else
The units are wrong!
Print an error message and stop processing
let milimeter = inches/25.4
let foot = centimeters/30.48
let Yard = meter/0.9144
let mile = kilometers/1.609
let meter = centimeter/100
dispay the results
public void VolumeConverter();{
Let measurement = TextIO.getDouble()
Let units = TextIO.getlnword();
if the units are Fluid Ounce
Let Fluid Ounce = measurement
else if the units are mililitres
Let Fluid Ounce = measurement*28.41
else if the units are Pint
Let Litres = measurement*0.568
else if the units are Quart
Let Litres = measurement*1.14
else if the units are Gallon
let litres = measurement*4.54
else if the unit are litres
let centilitres = measurement*100
else
The units are wrong!
Print an error message and stop processing
let mililitres = Fluid Ounce/28.4
let Pint = Litres/0.568
let Quart = Litre/1.14
let Gallon = Litres/4.54
let litre = centilitre/100
dispay the results
public void WeightConverter();{
Let measurement = TextIO.getDouble()
Let units = TextIO.getlnword();
if the units are Ounce
Let Ounce = measurement
else if the units are Grammes
Let Ounce = measurement*28.35
else if the units are Pound
Let kilograms = measurement*0.4536
else if the units are Stone
Let Kilogrammes = measurement*6.3503
else if the units are Longton
let metric tonne = measurement*1.016
else if the unit are Gramme
let Killogram = measurement*100
else
The units are wrong!
Print an error message and stop processing
let Gramme = Ounce/28.35
let Pound = Kilogram/0.4536
let Stone = Killogrammes/6.3503
let Longton = metrictonne/1.016
let Gramme = Kilogram/100
dispay the results
private static void createAndShowGUI();{
ConvertValues newScreen = new ConvertValues();
}My main problem is how to assign events to the button so that it preforms a calculation. [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons
Also, use the "Code Formatting Tags" when posting code so it retains its original formatting and is readable. -
( im new to java) How do I increase number of columns in a JTable ?
I am dooing a small calculating program in school and can't figure out how to change the amount of columns in a JTable, my programming skills sofar are extremely basic and therefore we are using the netbeans GUI to create our windows. The code generated by the GUI cannot be edited and I have tried to copy paste the code into Eclipse but it didn't work.
I have a fair idea of where in the code you can preform the things I want but I need to do it in the grapical interface.
any suggestions are very much appriciated.my programming skills sofar are extremely basic and therefore we are using the netbeans GUI to create our windows.Using and IDE doesn't not make it easier. As you've found out it only makes it harder since you can't edit the code and take full control.
Read the Swing tutorial, it contains plenty of example for building GUI applications:
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
I don't really understand your question, because if you create the table correctly, then then is no need to increase the number of columns. However, the table does support an addColumn(....) method. -
can you give me the order for graphical,java,abap and xslt mappings in preformance point of view?
There are some unfortunate things about XI compared to other ESB EAI framework.
XI just use JAVA, J2EE and Web service technology for design and configuration phase. In run time ABAP engine is the main player which use J2EE engine as RFC destination to handle supporting work.
However other ESB EAI Engine such as Aqualogic, Websphere, Mule, TIBCO etc depend on JAVA as a core engine.
Regarding the view of a programmer who do not have a clue on the powe of JAVA and XSLT and at the same time have to depend on the burdon of some architectural flops in XI , it is nice to say that for the sake of goodness use ABAP mapping as much as possible for complicated mapping.
However provided that XI will one day use JAVA as a core engine and use JAVA technology as a main stream then XSLT and JAVA mapping can rock with even a 2 CPU production machine.
For example, I have a SAP Integration with 45 different plant system for a Telecom supply chain in USA where 2 instance of weblogic server with J2EE and JAVA can handle 35,000 master data changes (IDOCS) from SAP to all plants in 4 hours without breaking a single one. It took more than 3 days to load into the same SAP master data system using ABAP technologies and may be 60 CPU machines too.
If you know what is the power of XSLT, JAVA caching, power of JAVA POJOS, HEAP tuning and provided you have a right infrastructure supported by ESB EAI features such as transformation, translation, routing, then JAVA is the solution.
But if you are from a back ground of customization project, not much clue of software programming and dragged to certain believe then JAVA is not a solution.
I hope to see one day SAP platform use JAVA and J2EE technologies with its full power and keep the right steps SAP took with Netweaver platform.
Thanks -
How would I implement a SlotQueue in java?
I am currently writing a MUD server in Java and I use Jython scripting to make everything dynamic however there is one drawback with that.. exec() eval() and execfile() are very very expensive so I created a series of worker threads that run and stay in the Jython script and if I make any changes to any of the script it can reload them. On the event side it preforms pretty well and using a DelayQueue I was able handle 30,000 events/sec on a 2.5ghz intel celeron.
My problem has to do with the players.. Having one thread per player appears that it would be bad for performance as someday I may have hundreds. If I make one thread that handles all the IO and passes work into a queue read by the worker threads I run into a problem. There is a race condition where a user might attack someone and then go east, there is a chance two of the worker threads might get both requests at the same time and if the one to move the player easy executed fast the player would find himself in a room by himself trying to attack something that isn't there.
I need some way to guarantee that the commands players enter will be handled in the order that the player issued them.
My idea was sort of a slot queue. The requirements would be that each element (a player) could only enter one item in the queue at a time and could not enter another item until the worker threads were done answering that request.
The queue could be any type of queue and each player could have their own semaphore that inits to 1. When the io thread puts an object in there it acquire a permit on the player's semaphore and block if there was none. When the worker threads pull from the queue it could release a permit for that player's semaphore.
So my final question is.. in the long run should I fear any issues with this or will it even perform better concurrently than each user having its own thread which processes its own requests? Better yet, is there a better way to process commands from player in order without ruining all concurrency?however I don't know what
the angle of the clock hand would be, hence the
question. If I knew that I wouldn't have asked it.Angles in radians go from 0 to 2*pi. The clock goes
from 0 to 60. Set up a ratio.Seems pretty simple to me. Cicle 360 degrees. clock 60 positions. Might it be that each tick of the clock is 6 degrees ? Exercise left to the reader. -
Azure instance number changes gives wrong status to the java tomcat app
The documentation of microsoft says ( http://azure.microsoft.com/blog/2011/01/04/responding-to-role-topology-changes/ )
you receive a changing and a changed event when the instance number is changed.
In real live i see a changing, a changed and a stopping event.
After that my java application doesn't run the contextDestroyed, but does run the contextInitialized again.
I don't call the cancel methode on the changing event. So a stopping event is unexpected.
So why does i receive a stopping event? Is this a bug? And while i received a stopping event the server didn't preform a reboot, but my java app contextInitialized is called again? So why is that?
Any inside is appreciated?Hi sir,
For this issue, I recommend you can refer to this blog:http://azure.microsoft.com/blog/2013/01/14/the-right-way-to-handle-azure-onstop-events/
When you received the onstopping event, the cloud service ILB could stop dispatch the request to this instance. And your instance may have 5 min to handler the uncompleted processor. And I wondered know how to code in your onstop() method in your project.
If your onstop method is canceled, you maybe not receive the instance reboot.
Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Will java programs become slower with generics?
This is not a question, more lika general discussion. I'd like to know what you think.
I fear that the average java developer will become accustom to the new features of java and write inefficient code. I have included a sample program that shows new code vs. old code. Altough the new code is esier to read, it's also alot slower.
For instance the foreach instruction is using an iterator which is created and then iterated. When the loop exits the Iterator is garanage collected. Better performance would be achieved if there was a "Getable" interface of some sort was implemented and that the foreach simply asked the collections class for the next object in line. Perhapps if the ArrayList cached it's Iterator objects, somehow. (I'm not suggesting any of the solutions above. I'm just trying to make a point.)
Also regarding generics and enumerations it's easy to see how they will slow down the application. It gets even scarier when you consider that important foundation classes are updated with these new features. A small change in some AWT class may have unforeseen repercussions throughout all gui applications.
Gafter, if you read this, is there any tests made to see if this is true. Is performance affected by the new features? Will old style code be replace by new style code in the foundation classes (awt/swing/.../... etc.).
ArrayList<String> ss = new ArrayList<String>();
for (int i = 0; i < 100; i++) ss.add("hello");
// "new" java ... completes in 6.43 seconds
long t1 = System.nanoTime();
for (int i = 0; i < 1000000; i++)
for (String s : ss)
System.out.println(System.nanoTime()-t1);
// "old" java ... completes in 2.58 seconds
long t2 = System.nanoTime();
for (int i = 0; i < 1000000; i++)
for (int j = 0, size = ss.size(); j < size; j++)
String s = ss.get(j);
System.out.println(System.nanoTime()-t2);Adapting Neal's example for JDK 1.4:
private static final String[] strArray = new String[0];
private static void withToArray() {
List ss = new ArrayList();
for (int i = 0; i < 100; i++) ss.add("hello");
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++)
String[] ssArray = (String[]) ss.toArray(strArray);
for (int j=0; j < ssArray.length; j++) {
String s = ssArray[j];
System.out.println(System.currentTimeMillis()-t1);
private static final String[] strArray100 = new String[100];
private static void withToArrayAndCheatingOnLength() {
List ss = new ArrayList();
for (int i = 0; i < 100; i++) ss.add("hello");
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++)
String[] ssArray = (String[]) ss.toArray(strArray100);
for (int j=0; j < ssArray.length; j++) {
String s = ssArray[j];
System.out.println(System.currentTimeMillis()-t1);
private static void withToArrayAndCheatingOnLengthLocalVar() {
List ss = new ArrayList();
for (int i = 0; i < 100; i++) ss.add("hello");
final String[] localStrArray100 = new String[100];
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++)
String[] ssArray = (String[]) ss.toArray(localStrArray100);
for (int j=0; j < ssArray.length; j++) {
String s = ssArray[j];
System.out.println(System.currentTimeMillis()-t1);
} Allocating the string[] every time: 5812
Allocating the correctly sized string[] once, as a private final static: 2953
Allocating the correctly sized string[] once, as a final local var: 3141
Interesting that the private final static is 90ms faster than the local variable, fairly consistently.
What's interesting about that though, is that we're not iterating strArray100, we're iterating over ssArray, so its not clear why it should make a difference. If I modify things a little more:
private static void withToArrayAndLoopOptimization() {
List ss = new ArrayList();
for (int i = 0; i < 100; i++) ss.add("hello");
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++)
String[] ssArray = (String[]) ss.toArray(strArray100);
final int length = ssArray.length;
for (int j=0; j < length; j++) {
String s = ssArray[j];
System.out.println(System.currentTimeMillis()-t1);
private static void withToArrayAndLoopOptimizationLocalVar() {
List ss = new ArrayList();
for (int i = 0; i < 100; i++) ss.add("hello");
final String[] localStrArray100 = new String[100];
long t1 = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++)
String[] ssArray = (String[]) ss.toArray(localStrArray100);
final int length = ssArray.length;
for (int j=0; j < length; j++) {
String s = ssArray[j];
System.out.println(System.currentTimeMillis()-t1);
} With private static final and loop optimization: 2937
With local variable and loop optimization: 2922
Now the different has disappeared: in fact, the numbers are exactly the same on many runs. You have to make 'length' final to get the best speed.
I guess I'm disappointed that in 2004, Java 1.4 javac & Hotspot combined still cannot spot the simplest loop optimization in the book.... always assuming that's actually causing the preformance difference. My gut is telling me its something else causing the difference because all of the inner loops are iterating over ssArray, not strArray100 (wherever that happends to be declared).
Someone care to run Neal's example on 1.5 and see if they've managed to optimize further under the covers? -
Edit .swf templates by using java
Hello
Is any body use java to insert text in preformed swf templates.
I use anotherbigidea api for this.
If anybody have experience to do this than plz. help me.& provide me a little example of this
ThanksI am trying to write a java program to read a swf file
into bytestream and then try to open the swf file from
the bytestream, can any friends here know is it feasibile?
If not, any other suggestion?Open with what? Which SWF (flash?) reader are you using?
After reading the swf bytestream then try
to manipulate its header information so that
user cannot open the swf file by double click the file.For most users simply renaming the extention from .swf to .AnythingElse will render it un-doubleclickable. -
Error while running a Java Program
Can anyone help me,
I am getting the following error while running a Java program, Below is the exception thrown, please help.
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:425)
at java.nio.DirectByteBuffer.putChar(DirectByteBuffer.java:463)
at org.jetel.data.StringDataField.serialize(StringDataField.java:295)
at org.jetel.data.DataRecord.serialize(DataRecord.java:283)
at org.jetel.graph.DirectEdge.writeRecord(DirectEdge.java:216)
at org.jetel.graph.Edge.writeRecord(Edge.java:288)
at com.tcs.re.component.RESummer1.run(RESummer1.java:505)
java.nio.BufferOverflowException
at java.nio.Buffer.nextPutIndex(Buffer.java:425)
at java.nio.DirectByteBuffer.putChar(DirectByteBuffer.java:463)
at org.jetel.data.StringDataField.serialize(StringDataField.java:295)
at org.jetel.data.DataRecord.serialize(DataRecord.java:283)
at org.jetel.graph.DirectEdge.writeRecord(DirectEdge.java:216)
at org.jetel.graph.Edge.writeRecord(Edge.java:288)
at com.tcs.re.component.RECollectCont.run(RECollectCont.java:304)Ok, let's see. Write the following class:
public class Grunt {
public static void main(String[] args) {
System.out.println("Hello Mars");
}Save it as "C:\Grunt.java", compile by typing:
javac c:\Grunt.javaRun by typing:
java -classpath "C:\" GruntDoes it say "Hello Mars"? If yes, go back to your program and compare for differences (maybe you used the "package" statement?).
Regards -
Erro de SYSFAIL e Queda do Ambiente JAVA (PI)
Bom Dia
Estou num projeto de NFe e atualmente esta acontecendo o seguinte cenário de Erros:
Na SMQ2 , quando apresenta um aumento nas filas de Mensagens , aparece SYSFAIL em determinadas Filas , todas as outras travam , aumenta o numero de Filas.
Com essa mensagem de SYSFAIL nas filas , o serve0 (Parte JAVA do PI) cai e após isso estou tendo que efetuar manualmente um STOP/START em todos os canais de comunnicação para que os R/3 voltem a emitir NFe.
Isso esta ocorrendo com mais frequência após inserir uma nova empresa para emissão de NFe.
Alguem poderia me ajudar a entender por que ocorre o SYSFAIL as mensagens travam e derruba o ambiente JAVA ?
Sérgio.1º) Erro: Commit Fault: com.sap.aii.af.rfc.afcommunication.RfcAFWException:SenderA
2º) Foi alterado o numero de Filas O numero de Filas foi alterado , mas não consigo ver esse parametros na RZ10 , tem 3 entradas : X32_DVEBMGS32_NFISAP ; DEFAULT ; START_DVEBMGS32_NFISAP nessa transação ...onde eu vejo isso
3º) Esse parametro não tem nessa transação (/usr/sap//DVEBMGS00/j2ee/cluster/server0/log/). em qual desses diretórios abaixo eu encontro esse parametro ?
Existe esses:
DIR_ATRA /usr/sap/X32/DVEBMGS32/data
DIR_BINARY /usr/sap/X32/DVEBMGS32/exe
DIR_CCMS /usr/sap/ccms
DIR_CT_LOGGIN /usr/sap/X32/SYS/global
DIR_CT_RUN /usr/sap/X32/SYS/exe/run
DIR_DATA /usr/sap/X32/DVEBMGS32/data
DIR_DBMS /usr/sap/X32/SYS/SAPDB
DIR_EXECUTABLE /usr/sap/X32/DVEBMGS32/exe
DIR_EXE_ROOT /usr/sap/X32/SYS/exe
DIR_GEN /usr/sap/X32/SYS/gen/dbg
DIR_GEN_ROOT /usr/sap/X32/SYS/gen
DIR_GLOBAL /usr/sap/X32/SYS/global
DIR_GRAPH_EXE /usr/sap/X32/DVEBMGS32/exe
DIR_GRAPH_LIB /usr/sap/X32/DVEBMGS32/exe
DIR_HOME /usr/sap/X32/DVEBMGS32/work
DIR_INSTALL /usr/sap/X32/SYS
DIR_INSTANCE /usr/sap/X32/DVEBMGS32
DIR_LIBRARY /usr/sap/X32/DVEBMGS32/exe
DIR_LOGGING /usr/sap/X32/DVEBMGS32/log
DIR_MEMORY_INSPECTOR /usr/sap/X32/DVEBMGS32/data
DIR_ORAHOME /oracle/X32/102_64
DIR_PAGING /usr/sap/X32/DVEBMGS32/data
DIR_PUT /usr/sap/X32/put
DIR_PERF /usr/sap/tmp
DIR_PROFILE /usr/sap/X32/SYS/profile
DIR_PROTOKOLLS /usr/sap/X32/DVEBMGS32/log
DIR_REORG /usr/sap/X32/DVEBMGS32/data
DIR_ROLL /usr/sap/X32/DVEBMGS32/data
DIR_RSYN /usr/sap/X32/DVEBMGS32/exe
DIR_SAPHOSTAGENT /usr/sap/hostctrl
DIR_SAPUSERS ./
DIR_SETUPS /usr/sap/X32/SYS/profile
DIR_SORTTMP /usr/sap/X32/DVEBMGS32/data
DIR_SOURCE /usr/sap/X32/SYS/src
DIR_TEMP /tmp
DIR_TRANS /usr/sap/trans
DIR_TRFILES /usr/sap/trans
DIR_TRSUB /usr/sap/trans -
Starting deployment prerequisites: error in BI-Java installation sapinst
Hi all,
We are in process updating Bw 3.5 to BI 7.0 we hace sucessfully completed the Upgrade but while installing Bi java thru Sapinst in third step like java instance installtion i was stck with the below error.
We have downloaded the Cryptographic file and placed in jdk folder still the same problem is coming.
Please suggest...
Thanks,
Subhash.G
Starting deployment prerequisites:
Oct 13, 2007 2:42:18 AM Error: Creation of DataSource for database "BWQ" failed.
Original error message is:
com.sap.sql.log.OpenSQLException: Error while accessing secure store: Encryption or decryption is not possible because the full version of the SAP Java Crypto Toolkit was not found (iaik_jce.jar is required, iaik_jce_export.jar is not sufficient) or the JCE Jurisdiction Policy Files don't allow the use of the "PbeWithSHAAnd3_KeyTripleDES_CBC" algorithm..
Stack trace of original Exception or Error is:
com.sap.sql.log.OpenSQLException: Error while accessing secure store: Encryption or decryption is not possible because the full version of the SAP Java Crypto Toolkit was not found (iaik_jce.jar is required, iaik_jce_export.jar is not sufficient) or the JCE Jurisdiction Policy Files don't allow the use of the "PbeWithSHAAnd3_KeyTripleDES_CBC" algorithm..Problem solved followed the notes 1063396.
-
If Statement in java.awt paint
import java.applet.Applet; //bring in the applet class
import java.awt.*; //bring in the graphics class
import java.awt.event.*; //bring in the event class
import java.text.DecimalFormat; //bring in the decimal format class
import java.lang.Float; //bring in the float class
public class Bmi extends Applet implements ActionListener { //begin program and start ActionListener
Label weight, height; //define Label variable
TextField weighttext, heighttext; //define TextField variables
Button calculate; //define button variables
float index, wt, ht, max, min; //define float variables
DecimalFormat fmt2 = new DecimalFormat("#.00"); //set decimal format for reals
public void init() { //begin init()
weight = new Label("Please enter your weight in Kg. (2 decimal places): "); //define content of Label weight
weighttext = new TextField(6); //define size of TextField
height = new Label("Please enter your height in Metres (2 decimal places): "); //define content of Label height
heighttext = new TextField(5); //define size of TextField
calculate = new Button("Calculate!!"); //define content of Button
add(weight); //add Label weight to the GUI
add(weighttext); //add TextField weighttext to the GUI
add(height); //add Label height to the GUI
add(heighttext); //add TextField heighttext to the GUI
add(calculate); //add button calculate to the GUI
calculate.addActionListener(this); //wait for button to be returned
wt = 0; //reset wt to 0
index = 0; //reset index to 0
ht = 0; //reset ht to 0
max = 0; //reset max to 0
min = 0; //reset min to 0
public void actionPerformed( ActionEvent e ) { //run upon return of button
wt = Float.parseFloat(weighttext.getText()); //convert weighttext from String to Float
ht = Float.parseFloat(heighttext.getText()); //covert heighttext from String to Float
repaint(); //refresh paint area
public float indexer() //begin indexer method
float ind; //delare local variable ind
ind = wt/(ht*ht); //perform calculation
return ind; //make indexer() the value of variable ind
} // end of indexer method
public float maxWeight() //begin maxWeight method
float maxwt; //declare local variable maxwt
final float UPPER = 25.0f; //declare variable UPPER as a float with a decimal value of 25.0
maxwt = UPPER*ht*ht; //perform calculation
return maxwt; //make maxWeight() the value of variable maxwt
} // end of maxWeight method
public float minWeight() //begin minWeight method
float minwt; //declare local variable minwt
final float LOWER= 20.0f; //declare variable LOWER as a float with a decimal value of 20.0
minwt = LOWER*ht*ht; //perform calculation
return minwt; //make minWeight() the value of variable minwt
} // end of minWeight method
public void paint(Graphics g) //begin paint method, define g as Graphics
index=indexer(); //covert method indexer() to variable index
max=maxWeight(); //convert method maxWeight() to variable max
min=minWeight(); //convert method minWeight() to variable min
g.setFont(new Font("Verdana", Font.ITALIC, 15)); //define font, weight and size
g.setColor(new Color(90,90,90)); //set new colour
g.drawRect(5,100,300,75); //define size of rectangle
g.setColor(new Color(255,107,9)); //set new colour
g.drawString("BMI is " + fmt2.format(index) + " for " + fmt2.format(wt) + "kg",20,120); //create string in paint, define its on screen position
g.drawString("Maximum bodyweight is " + fmt2.format(max) + "kg", 20,140); //create string in paint, define its on screen position
g.drawString("Minimum bodyweight is " + fmt2.format(min) + "kg", 20,160); //create string in paint, define its on screen position
} // end of paint method
} // end of Bmi classI have written the above code to calculate someones BMI (Body Mass Index). Basically as you can see it recieves a weight and height from the user and calculates the rest. But whilst that good I would like to know how I can make it tell the user something to the effect of "Your overweight" or "Your underweight". The if statement runs like this:
if (wt > max)This forum doesn't quite handle <> properly. The greater and less than symbols. So above you will see > this is the html character code for a greater than symbol so please read it as such.
And then if wt is greater than max then it will say "Your overweight".
But I can't figure out how to include it in the above program. Becuase it won't run in paint, atleast it won't the way I have done it previously. So can you think of any other ways?
Help much appreciated,
SimonThanks very much that works well.
Simon
My code now looks like this: import java.applet.Applet; //bring in the applet class
import java.awt.*; //bring in the graphics class
import java.awt.event.*; //bring in the event class
import java.text.DecimalFormat; //bring in the decimal format class
import java.lang.Float; //bring in the float class
public class Bmi extends Applet implements ActionListener { //begin program and start ActionListener
Label weight, height; //define Label variable
TextField weighttext, heighttext; //define TextField variables
Button calculate; //define button variables
float index, wt, ht, max, min; //define float variables
DecimalFormat fmt2 = new DecimalFormat("#.00"); //set decimal format for reals
public void init() { //begin init()
weight = new Label("Please enter your weight in Kg. (2 decimal places): "); //define content of Label weight
weighttext = new TextField(6); //define size of TextField
height = new Label("Please enter your height in Metres (2 decimal places): "); //define content of Label height
heighttext = new TextField(5); //define size of TextField
calculate = new Button("Calculate!!"); //define content of Button
add(weight); //add Label weight to the GUI
add(weighttext); //add TextField weighttext to the GUI
add(height); //add Label height to the GUI
add(heighttext); //add TextField heighttext to the GUI
add(calculate); //add button calculate to the GUI
calculate.addActionListener(this); //wait for button to be returned
wt = 0; //reset wt to 0
index = 0; //reset index to 0
ht = 0; //reset ht to 0
max = 0; //reset max to 0
min = 0; //reset min to 0
public void actionPerformed( ActionEvent e ) { //run upon return of button
wt = Float.parseFloat(weighttext.getText()); //convert weighttext from String to Float
ht = Float.parseFloat(heighttext.getText()); //covert heighttext from String to Float
repaint(); //refresh paint area
public float indexer() //begin indexer method
float ind; //delare local variable ind
ind = wt/(ht*ht); //perform calculation
return ind; //make indexer() the value of variable ind
} // end of indexer method
public float maxWeight() //begin maxWeight method
float maxwt; //declare local variable maxwt
final float UPPER = 25.0f; //declare variable UPPER as a float with a decimal value of 25.0
maxwt = UPPER*ht*ht; //perform calculation
return maxwt; //make maxWeight() the value of variable maxwt
} // end of maxWeight method
public float minWeight() //begin minWeight method
float minwt; //declare local variable minwt
final float LOWER= 20.0f; //declare variable LOWER as a float with a decimal value of 20.0
minwt = LOWER*ht*ht; //perform calculation
return minwt; //make minWeight() the value of variable minwt
} // end of minWeight method
public void you(Graphics g)
String statement;
if(wt > max) statement="You are very fat";
else if(wt < min) statement="You are very thin";
else statement="You are in the recommended weight range for your height";
g.drawString(statement, 20,210);
public void paint(Graphics g) //begin paint method, define g as Graphics
you(g);
index=indexer(); //covert method indexer() to variable index
max=maxWeight(); //convert method maxWeight() to variable max
min=minWeight(); //convert method minWeight() to variable min
g.setFont(new Font("Verdana", Font.ITALIC, 15)); //define font, weight and size
g.setColor(new Color(90,90,90)); //set new colour
g.drawRect(5,100,300,75); //define size of rectangle
g.setColor(new Color(255,107,9)); //set new colour
g.drawString("BMI is " + fmt2.format(index) + " for " + fmt2.format(wt) + "kg",20,120); //create string in paint, define its on screen position
g.drawString("Maximum bodyweight is " + fmt2.format(max) + "kg", 20,140); //create string in paint, define its on screen position
g.drawString("Minimum bodyweight is " + fmt2.format(min) + "kg", 20,160); //create string in paint, define its on screen position
} // end of paint method
} // end of BmiThanks again,
Simon -
SSO java sample application problem
Hi all,
I am trying to run the SSO java sample application, but am experiencing a problem:
When I request the papp.jsp page I end up in an infinte loop, caught between papp.jsp and ssosignon.jsp.
An earlier thread in this forum discussed the same problem, guessing that the cookie handling was the problem. This thread recommended a particlar servlet , ShowCookie, for inspecting the cookies for the current session.
I have installed this cookie on the server, but don't see anything but one cookie, JSESSIONID.
At present I am running the jsp sample app on a Tomcat server, while Oracle 9iAS with sso and portal is running on another machine on the LAN.
The configuration of the SSO sample application is as follows:
Cut from SSOEnablerJspBean.java:
// Listener token for this partner application name
private static String m_listenerToken = "wmli007251:8080";
// Partner application session cookie name
private static String m_cookieName = "SSO_PAPP_JSP_ID";
// Partner application session domain
private static String m_cookieDomain = "wmli007251:8080/";
// Partner application session path scope
private static String m_cookiePath = "/";
// Host name of the database
private static String m_dbHostName = "wmsi001370";
// Port for database
private static String m_dbPort = "1521";
// Sehema name
private static String m_dbSchemaName = "testpartnerapp";
// Schema password
private static String m_dbSchemaPasswd = "testpartnerapp";
// Database SID name
private static String m_dbSID = "IASDB.WMDATA.DK";
// Requested URL (User requested page)
private static String m_requestUrl = "http://wmli007251:8080/testsso/papp.jsp";
// Cancel URL(Home page for this application which don't require authentication)
private static String m_cancelUrl = "http://wmli007251:8080/testsso/fejl.html";
Values specified in the Oracle Portal partner app administration page:
ID: 1326
Token: O87JOE971326
Encryption key: 67854625C8B9BE96
Logon-URL: http://wmsi001370:7777/pls/orasso/orasso.wwsso_app_admin.ls_login
single signoff-URL: http://wmsi001370:7777/pls/orasso/orasso.wwsso_app_admin.ls_logout
Name: testsso
Start-URL: http://wmli007251:8080/testsso/
Succes-URL: http://wmli007251:8080/testsso/ssosignon.jsp
Log off-URL: http://wmli007251:8080/testsso/papplogoff.jsp
Finally I have specified the cookie version to be v1.0 when running the regapp.sql script. Other parameters for this script are copied from the values specified above.
Unfortunately the discussion in the earlier thread did not go any further but to recognize the cookieproblem, so I am now looking for help to move further on from here.
Any ideas will be greatly appreciated!
/MadsPierre - When you work on the sample application, you should test the pages in a separate browser instance. Don't use the Run Page links from the Builder. The sample app has a different authentication scheme from that used in the development environment so it'll work better for you to use a separate development browser from the application testing browser. In the testing browser, to request the page you just modified, login to the application, then change the page ID in the URL. Then put some navigation controls into the application so you can run your page more easily by clicking links from other pages.
Scott
Maybe you are looking for
-
I recently got an iPhone 4, and I set up an Apple ID of my own. I would like to put music on my phone, but all of my music is under another Apple ID and it won't let me add music from that account onto my phone. How do I add the music I would like?
-
ive tried everything suggested to resolve the unhappy icon on my clickwheel ipod and cannot seem to resolve the issue. it is no longer recognized by my computer when plugged in and will not play any songs or turn on at this point, wont charge nothing
-
I got the spinning wheel when trying to boot up today, so I'm trying to reload the OS, however when I try to do this it tells me my apple id has not purchased the os. what do I do?
-
Any of you used the bowsers Sunrise1.7.4 or icab4.2.0?
Have any of you had any experience with either of the browsers sunrise1.7.4 or icab4.2.0 ?
-
Question about @SuppressWarnings()
Hi all, I use for on collection and the compiler give me a warning to use for each loop. I can't use the for each loop in this section beacuse i get generic with wildcard, List<? extends Number> listOfUnknown My question is what is the right warning