Can you figure out what was the problem in this simple 3 liner code?
Hello, below is a class to demonstrate a problem I see that I can't understand. I create an instance of the enclosing
class at class level, another instance in static main method. Class below fails at run time with stack overflow exception. It's all fine if one of those two instantiation steps is removed, What is wrong can anyone any ideas?
public class App
// create instance of this class
App app = new App();
public static void main( String[] args )
// create instance of this class again.
App app2 = new App();
System.out.println( "Hello World!" );
}
As soon as a new instance of 'App' is created, 'App app = new App();' is called, which calls 'App app = new App();' etc. Hence the stack overflow.
When you remove 'App app = new App();', obviously, the stack overflow does not occur. And when your remove 'App app2 = new App();' the 'App' class is never instantiated and therefore, the exception is also not thrown.
Similar Messages
-
Can't figure out what is the code
Hi
I got following macro that will help me to run certain transaction.
I just can't figure out where comments ends and where code starts so I was unable to run it for like 3 hours now.
In other words
I am trying to use Excel Macro that will get to active transaction in SAP and do waht I have recorded.
'SAPGUI Macro for updating SAP from Excel data 'Prerequisites: '1. Script Recording and Playback from the SAPGui must be enabled by admin '2. The Excel list must be set up from top left corner of a worksheet '3. The worksheet with data must be the active sheet '4. There is no error handling. Build it yourself! '5. The script will update the active (current) SAP transaction'Instructions for use 'Record a macro of your update actions. 'Paste the session.findById stuff between the <== and ==> markers'Edit the literal values and replace with Trim(CStr(objSheet.Cells(x, y).Value)) 'where x and y are the row and column counters'Open up your Excel sheet with data (row 1 is ignored here) 'Fire the macro! '===========BEGIN BOILERPLATE=================== REMSet up connection to the SAP screen: If Not IsObject(application) Then Set SapGuiAuto = GetObject("SAPGUI") Set application = SapGuiAuto.GetScriptingEngine End If If Not IsObject(connection) Then Set connection = application.Children(0) End If If Not IsObject(session) Then Setsession = connection.Children(0) End If If IsObject(WScript) Then WScript.ConnectObject session, "on" WScript.ConnectObject application, "on" End If REMSet up connection to the Excel data to be keyed into SAP: Dim objExcel Dim objSheet, intRow, i Set objExcel = GetObject(,"Excel.Application") Set objSheet = objExcel.ActiveWorkbook.ActiveSheet session.findById("wnd[0]").maximize
'===========END BOILERPLATE=====================
'REM Example: Mark material for deletion in Plant using MM06 For i = 2 to objSheet.UsedRange.Rows.Count 'Assuming there is a header rowREM Find a cell and put its value in: REM Note: The section of the Script shown below can be recorded ' and edited to pick data from the Excel sheetstrCN = Trim(CStr(objSheet.Cells(i, 1).Value)) strWerks = Trim(CStr(objSheet.Cells(i, 2).Value)) '<== session.findById("wnd[0]/usr/ctxtRM03G-MATNR").text = strCN session.findById("wnd[0]/usr/ctxtRM03G-WERKS").text = strWerks session.findById("wnd[0]/tbar[0]/btn[0]").press session.findById("wnd[0]/usr/chkRM03G-LVOMA").selected = false session.findById("wnd[0]/usr/chkRM03G-LVOWK").selected = truesession.findById("wnd[0]/tbar[0]/btn[11]").press 'session.findById("wnd[0]/tbar[0]/btn[0]").press '==> NextOk macro works and triggers actions from recorder. I was doing it with hope I will select data in SAP and paste in Excel AND/OR export file from SAP with data.
If I record select column and then copy it. Script is recorded until selection . It ignores copy (i tried use mouse right click and copy AND manual alt+F12 and then copy from context menu)
When I export recorder does open export window but does not writes the line relevant to clicking save.
I found such bits
'Choose the export format
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/tbar[0]/btn[0]").press
'Choose the export filename
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "test.txt"
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\Temp\"
'Export the file
session.findById("wnd[1]/tbar[0]/btn[0]").press
But they dont seem to be relevant to my previous macro.
Any quick fix to get data out of Excel -
Can any one tell what is the problem in this code?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
import java.util.*;
public class AppletTest2 extends JApplet implements ActionListener,MouseMotionListener,WindowListener{
JFrame fr = new JFrame("Visual Tool -- Work Flow Editor");
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JButton sButton = new JButton("Source");
JButton rButton = new JButton("Redirection");
JButton dButton = new JButton("Destination");
JButton connect = new JButton("Connect");
BasicStroke stroke = new BasicStroke(2.0f);
int flag = 1 ;
Vector lines = new Vector();
JButton sBut,rBut,dBut;
int x1 = 0 ;
int y1 = 0 ;
int x2 = 0 ;
int y2 = 0;
int x3 = 0;
int y3 = 0;
int i=0;
int j=0;
int k=0;
int l = 100;
int b = 50;
public void init(){
/*********Frame ******************/
fr.getContentPane().setLayout(new BorderLayout());
fr.setSize(700,500);
fr.getContentPane().add(panel1,BorderLayout.CENTER);
fr.getContentPane().add(panel2,BorderLayout.SOUTH);
fr.addWindowListener(this);
/*****************PANEL 1*********************/
panel1.setLayout(null);
panel1.setBounds(new Rectangle(0,0,400,400));
panel1.setBackground(new Color(105,105,205));
/************************PANEL 2 *************/
panel2.setLayout(new FlowLayout());
panel2.setBackground(new Color(105,205,159));
panel2.add(sButton);
panel2.add(rButton);
panel2.add(dButton);
panel2.add(connect);
connect.setToolTipText("Use this button after selecting From and To position to connect");
/***************************LISTENER********************/
sButton.addActionListener(this);
rButton.addActionListener(this);
dButton.addActionListener(this);
connect.addActionListener(this);
fr.setVisible(true);
fr.setResizable(false);
} // init clse
/************************** START METHOD **********************************************/
public void start(){
System.out.println("inside start");
paint(panel1.getGraphics());
/*******************************APPLET METHODS **************************************************/
public void stop(){}
public void destroy(){}
/******************************MOUSE MOTION LISTENERS METHOD*************************************/
public void mouseMoved(MouseEvent e){System.out.println("moved");}
public void mouseDragged(MouseEvent e){System.out.println("dragged");}
/***************************************ACTION EVENT IMPLEMENTAION *******************************/
public void actionPerformed(ActionEvent e){
if (e.getSource().equals(sButton)){
sourceObject("Source Object");
else if (e.getSource().equals(rButton)){
redirectionObject("Redirection");
i = i+1;
else if (e.getSource().equals(dButton)){
destinationObject("Destination");
j= j+1;
else if (e.getSource().equals(connect)){
System.out.println("am inside connect");
paint(panel1.getGraphics());
else if(e.getSource().equals(sBut)){
System.out.println("am s button");
x1 = sBut.getX() + l;
y1 = sBut.getY() + (b/2);
else if(e.getSource().equals(rBut)){
System.out.println("am r button");
x2 = rBut.getX() ;
y2 = rBut.getY()+ b/2;
System.out.println("x2 : " + x2 + "y2 :" +y2 );
else if(e.getSource().equals(dBut)){
System.out.println("am d button");
x3 = dBut.getX();
y3 = dBut.getY()+ b/2;
} // action close
/**********************Main **********************************/
public static void main(String args[]){
JApplet at = new AppletTest2();
at.init();
at.start();
/********************my methods starts here *******************/
public void sourceObject(String name){
sBut = new JButton(name);
panel1.add(sBut);
sBut.setBounds(new Rectangle(20,208,l,b));
sBut.addActionListener(this);
System.out.println("am inside the source object") ;
public void redirectionObject(String name){
rBut = new JButton(name);
panel1.add(rBut);
rBut.setBounds(new Rectangle(290,208,l,b));
rBut.addActionListener(this);
System.out.println("am inside the redirection :" + j) ;
public void destinationObject(String name){
dBut = new JButton(name);
panel1.add(dBut);
System.out.println("am inside the destination object") ;
if (j == 0)
dBut.setBounds(new Rectangle(566,60,l,b));
System.out.println("am inside the destination:" + j) ;
} else if (j == 2)
dBut.setBounds(new Rectangle(566,208,l,b));
System.out.println("am inside the destination :" + j) ;
} else if (j == 1)
dBut.setBounds(new Rectangle(566,350,l,b));
System.out.println("am inside the destination :" + j) ;
dBut.addActionListener(this);
/* public void connectObject(Object obj1,Object obj2){
System.out.println("nothing");
/************************************* PAINT **************************/
public void paint(Graphics g){
System.out.println("inside paint");
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(stroke);
if(flag == 1){
System.out.println("inside flag");
int np = lines.size();
System.out.println(np);
for (int I=0; I < np; I++) {
Rectangle p = (Rectangle)lines.elementAt(I);
System.out.println("width" + p.width);
g2.setColor(Color.red);
g2.drawLine(p.x,p.y,p.width,p.height);
System.out.println(p.x +"" +""+ p.y + ""+ ""+ p.width+ "" + ""+ p.height);
flag = -1;
}else if(flag == -1){
if(x1 != 0 && y1 != 0 && x2 != 0 && y2 != 0 ){
// Graphics2D g2 = (Graphics2D) g;
// g2.setStroke(stroke);
g2.setColor(Color.red);
g2.drawLine(x1,y1,x2,y2);
lines.addElement(new Rectangle(x1,y1,x2,y2));
x1 = 0 ;y1 = 0 ;
x2 = 0 ;y2 = 0 ;
// g2.drawLine(100,100,200,200);
else if (x2 != 0 && y2 != 0 && x3 != 0 && y3 != 0 )
// Graphics2D g2 = (Graphics2D) g;
// g2.setStroke(stroke);
g2.setColor(Color.green);
g2.drawLine(x2,y2,x3,y3);
lines.addElement(new Rectangle(x2,y2,x3,y3));
x2 = 0; y2 = 0 ;
x3 = 0 ; y3 = 0 ;
else if (x1 != 0 && y1 != 0 && x3 != 0 && y3 != 0)
// Graphics2D g2 = (Graphics2D) g;
// g2.setStroke(stroke);
g2.setColor(Color.red);
g2.drawLine(x1,y1,x3,y3);
lines.addElement(new Rectangle(x1,y1,x3,y3));
x1 = 0; y1 = 0 ;
x3 = 0 ; y3 = 0 ;
// repaint();
/********************************WINDOW LISTENER IMPLEMENTATION *****************************/
public void windowActivated(WindowEvent we) {
flag = 1;
paint(panel1.getGraphics());
System.out.println("windowActivated -- event 1");
//start();
public void windowClosed(WindowEvent we) {
System.out.println("windowClosed -- 2");
public void windowClosing(WindowEvent we){
System.out.println("windowClosing -- 3");
public void windowDeactivated(WindowEvent we) {
System.out.println("windowDeactivated -- 4");
public void windowDeiconified(WindowEvent we) {
flag = 1;
System.out.println("windowDeiconified -- 5");
paint(panel1.getGraphics());
public void windowIconified(WindowEvent we) {
System.out.println("windowIconified -- 6");
//paint(panel1.getGraphics());
public void windowOpened(WindowEvent we) {
// flag = 1;
// paint(panel1.getGraphics());
System.out.println("windowopened -- 7");
The problem am facing here is that when i minimize the frame and maximize , my old lines are getting disappared.
For avoiding that i am storing the old coordinates and
try to redraw , when maximize.
but the lines are coming for flash of second and disappearing once again ?
can any one help?
thanks allVery interestingly the same code is repainting in
Linux SUSE,jdk1.3.
but not in WINNT , jdk 1.3
Any reason ?
Is the swing 100 % platform independenet ?????
Does swing also uses native thread ??? -
IPhone 5 storage completely full and can't figure out to fix the problem?
I got the iPhone 5c in August of last year. Previously, I had owned a flip-phone and only a flip-phone, so you can imagine that it was a big change. Though I know there is so much more that it can do (and so many things I have yet to discover), I mostly appreciated the phone for its photo and Internet capabilities. Only a few weeks after I got the phone, I went to a concert and, as you can imagine, the videos took up a lot of space on my phone. I also have a bad problem with saving screenshots, so I quickly filled up space with pictures. Once I realized it was reaching an overwhelming amount (and space was getting limited), I backed-up my iPhone to iTunes on my computer and deleted around 800 pictures. It barely freed up any space. I did this once or twice until one time I tried backing it up again and it would not let me, saying that there was not enough space to do the back-up. I don't quite know how that works, but after that, I just ignored my problem. Well, then my space was dwindling down close to zero. I deleted most of my apps, though it did not free up much at all because 11.4 GB of my 13.2 GB phone is from Photos/Videos.
My phone reached 0 bytes available in, I'm guessing, November of last year? To my surprise, I could still use some of the features on my phone. Internet, screenshotting (though I could no longer take pictures), and some of the apps (though they often would not load fully). This didn't last for long. One day, I wasn't able to open hardly any of my apps. Then it transitioned to my Internet closing out of itself every now-and-then. Well, currently (and I've been having these problems consistently for the past month or so), I can not open any apps. If I try to go to a website, it closes out of itself almost every single time. I never know if my texts go through because it never finishes the sending process (sometimes people say they get them, sometimes they don't). I cannot receive texts. I can't even try to delete my photos/videos because when I click "delete", it goes to my Home Screen (again, it closes out of itself) and when I check, the pictures/videos are still there. For the past month or so, the only thing my phone can do is call. Which, you know, defeats the purpose of an iPhone. Basically, I have gotten myself into quite a conundrum.
Is there a solution to my problem that does not involve restoring it to factory settings?Thank you for your reply! I just tried importing my pictures again. iTunes gave me the same message - that the storage was too full. I looked under summary, and I don't quite exactly know what usage numbers you are looking for, but it does say it is over capacity by 190.8 MB. However, when I plugged in my phone to the computer, it started to import pictures automatically into Dropbox. I just recently got Dropbox, so I did not have it the other times I tried to import. I managed to get the pictures onto my computer and, by some miracle, was able to delete a couple hundred from my phone. It also let me delete the long videos on my phone, which I've been trying to do for months. I went to my Storage and it now says I have 6.6 GB free (which was so amazing to see that I had to take a moment). I can take pictures now. I quickly updated a few apps and the space is still good. However, there are some apps that it still will not open (as in I open it up, then one second later it closes out). These seem to be the social media apps-- Twitter, Instagram, Facebook. Should I just delete them, then re-download? That will not mess anything up, correct? So far, Safari is working, which is a major relief.
How would I go about syncing things like contacts? -
What is the problem with this simple script
This shouls work to open safari:
tell application "Safari"
activate
end tell
But I get error:
error "Safari got an error: Connection is invalid." number -609
So what is wrong? Other apps work such as:
tell application "Adobe Bridge CS6"
activate
end tellAh the Devils in the details.
With the quit like that there is the potential for error. When I add the quit I see either Safari not opening or else I get the connection error also.
There are ways around this either put in a delay between the quit and the activate or else superficially check to see if Safari has quit.
so
tell application "Safari" to quit
repeat while application "Safari" is running
end repeat
tell application "Safari"
activate
end tell
or
tell application "Safari" to quit
delay 5 -- increase or decrease as needed
tell application "Safari"
activate
end tell -
What is the problem with this simple code?
import javax.swing.*;
public class TestThread extends JApplet implements Runnable
JPanel jp;
JLabel jb;
public void init()
jp=new JPanel();
jb=new JLabel("Botton");
getContentPane().add(jp);
jp.add(jb);
public static void main(String args[])
new TestThread().start();
public void run()
System.out.println("Jaison");
Y it not working...help me
contd............
<html>
<head>
</head>
<applet
code=TestThread.class
width=1450
height=1680>
</applet>
</html>Status bar says
Applet TestThread StartedYou do know that main isn't used by applets? It will not be executed by the browser.
Kaj -
Please tell me what is the problem with this code
Hai,
Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
I got the frame ,but the controls are not.
this is the code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ex2 extends JFrame
JButton b1;
JLabel l1,l2;
JPanel p1,p2;
JTextField tf1;
JPasswordField tf2;
public ex2()
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Another example");
setSize(500,500);
setVisible(true);
b1=new JButton(" ok ");
p1=new JPanel();
p1.setLayout(new GridLayout(2,2));
p2=new JPanel();
p2.setLayout(new BorderLayout());
l1=new JLabel("Name :");
l2=new JLabel("Password:");
tf1=new JTextField(15);
tf2=new JPasswordField(15);
Container con=getContentPane();
con.add(p1);
con.add(p2);
public static void createAndShowGUI()
ex2.setDefaultLookAndFeelDecorated(true);
public static void main(String ar[])
createAndShowGUI();
new ex2();
}import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ex2 extends JFrame
JButton b1;
JLabel l1,l2;
JPanel p1,p2;
JTextField tf1;
JPasswordField tf2;
public ex2()
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Another example");
b1=new JButton(" ok ");
p1=new JPanel();
p1.add(b1);
p2=new JPanel();
p2.setLayout(new GridLayout(2,2));
l1=new JLabel("Name :");
l2=new JLabel("Password:");
tf1=new JTextField(15);
tf2=new JPasswordField(15);
p2.add(l1);
p2.add(tf1);
p2.add(l2);
p2.add(tf2);
Container con=getContentPane();
con.add(p1, BorderLayout.NORTH);
con.add(p2, BorderLayout.CENTER);
pack();
setVisible(true);
public static void createAndShowGUI()
ex2.setDefaultLookAndFeelDecorated(true);
public static void main(String ar[])
createAndShowGUI();
new ex2();
} -
Because of a problem, I uninstalled Firefox once, reinstalled it and it ran. I had a problem so I uninstalled/reinstalled it again. Now it will not run. I get an error message saying that firefox is running and you can only run one at a time. I have uninstalled multiple times and can't figure out what is running. The is only one Firefox installed and it is not open. What does this mean and how do I fix it?
If you use ZoneAlarm Extreme Security then try to disable Virtualization.
*http://kb.mozillazine.org/Browser_will_not_start_up#XULRunner_error_after_an_update
See also:
*[[/questions/880050]] -
I have a strange problem. When I put my iphone 4S into my pocket (pants or coat) and move it around, the phone makes a beep noise/tone. I can't figure out what is causing the noise. It doesn't sound like any of my regular applications. Maybe it is the lock noise but I can't tell for sure. More movement makes more beeps. Even walking with my phone in my pocket creates beeps. The IOS is 7.0.4 (11B554a). Anyone else have this crazy problem?
Try This...
Close All Open Apps... Sign Out of your Account... Perform a Reset...
Reset ( No Data will be Lost )
Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
http://support.apple.com/kb/ht1430
If the issue persists...
Connect to iTunes on the computer you usually Sync with and Restore
http://support.apple.com/kb/HT1414
Make sure you have the Latest Version of iTunes (v11) Installed on your computer
iTunes free download from www.itunes.com/download -
I see "imac-54f9d5" under the "Shared" heading in my finder. I am not connected to any printers or other Mac devices. Is it possible that someone is remotely accessing my system? How can I figure out what this is?
is it your imac?
is it your your router's name?
are you by any chance connected to another wifi router then your own because the other one was open and not password protected? -
Can you figure out from a G4 logic board serial number what it is?
Can you figure out from a G4 logic board serial number what it is? for example if it is single or dual processor support, and the speed, i know you can check the case serial number in the apple site, but can't for the life of me figure out the logic board serial number, if any one could help identify what G4 it comes form that would be great, Can you figure out from a G4 logic board serial number what it is? KD30405K1P3UA
many thanksHi, Forrest!
The Chipmunk site was my first thought when I read the initial post, but although it returns a manufacturing date of the fourth week (Jan) of 2003, I'm not sure that's even accurate, since Chipmunk couldn't return any more info than that.
I wonder if an Apple Store Genius would/could look it up for him...
Regards,
Gary -
I probably misclicked when I activated the security lock on the iPhone and now I can not figure out what password I entered. Moreover, I have patches and funky looking phone so I can not restore iphine pres itunes. Please advice.
Your only recourse is to force it into DFU mode:
Turn your phone off and connect your cable to the computer, but not the device just yet. Start up iTunes. Now, hold down the home button on your phone and plug it in to the cable - don't let go of the button until iTunes tells you it's detected a phone in recovery mode. Now you can restore to factory settings. -
I recently received a WD My Book Studio external Hard drive and am installing it but can't figure out what the difference between wd turbo installer 64 and wd turbo installer is. Can someone tell me. Thanks in advance for all your help.
Oh ok, well that was what the test said prior to reformatting the hard drive. Now, it doesn't find any trouble no matter how many times I run it. That's what has me so confused, everything seems to check out and yet...I can't do anything, not even install the software!
-
Trouble with calculating fields. Can't select (check) fields. Also can't figure out what's wrong with a division field (percent) that I created. Keep getting the pop up that format of the field doesn't allow blah blah blah... Help!
1. Use the mouse to select the field and then press the space bar.
2. A null string is the same as zero. What is the result for division by zero? -
Can't figure out what I'm doing wrong
I'm using Studio 8 in Mac OS X (10.4.6). I've got some pdfs
uploaded to my site that are accessible through links one one of
the pages. I had to make changes to the pdfs and resave them. I
thought I uploaded them, but when I test the links it downloads the
old version and I can't figure out what I'm doing wrong. Here's
what I did.
This may be a dumb way to do things, but I saved the new
version and then dragged into the server file in
user-->Library-->Application
Support-->Macromedia-->Dreamweaver
8-->Configuration-->ServerConnections-->unnamed
server-->public_html (this is where all the other files are).
When I go back into Dreamweaver and open the pdf listed in the
Files window on the right (by control-clicking and selecting Open
with-->Acrobat) the correct version appears. I thought maybe
there was a delay or something, but I've waited and still the old
version is what you get from the site.
Is there an easier way to do this, or is something wrong
maybe? Many thanks in advance.> This may be a dumb way to do things, but I saved the new
version and then
> dragged into the server file in
user-->Library-->Application
> Support-->Macromedia-->Dreamweaver
Put the files in this Site's Local Site Folder.
If unsure of where you've specified this to be, look in this
site definition
(dw menu-->Sites-->Manage or Edit Sites)
If that path you've given above above is correct, it's
wrong....
Maybe you are looking for
-
How do I cross-reference photo folders?
My photos are organized in folders according to the week they were taken, and I want to keep it that way. But if I want to pull up just the photos that have my friend Brian in them, how can I do that? First off iPhoto is NOT an option. I have used se
-
I save the RoboForm2Go program on a flash drive and when I opened a site that I had saved the user name and password, the RoboForm2Go would show up in the taskbar with the site I opened so I could just click on it and it would automatically fill in t
-
I get message please contact customer support when trying to download
@
-
Calling BADIs in Web-Dynpro Application
Hi All, Is it possible to call BADIs in WebDynpro java ? If yes can anybody please send some document regarding this to me. Thanks & Regards, Amit Kade
-
Greetings! I have requirement to refresh dev db with prod data. But, I need to do this only for few tables. With sequences, constraints, etc., could you please suggest right way to do this? thanks,