Help with running multiple threads
I'm new to programming with threads. I want to know how to run
multiple threads at the same time. Particularly for making games
in Java which I'm also begining to learn. For running multiple
threads at the same time, do you have to put two run() methods
in the source? If not then how do you make two threads or more
run at the same time?
Thanks for helping.
For running multiple
threads at the same time, do you have to put two run()
methods
in the source? Hi there,
Each thread is presumably performing a task. You may be performing the same task multiple times or be performing different tasks at once. Either way, each task would typically be contained within the run() method of a class. This class would either be a subclass of java.lang.Thread (extends Thread) or would be an implementation of java.lang.Runnable (implements Runnable). In either case, you would define a method with signature (public void run()...). The difference comes into play when you wish to actually perform one of these tasks. With a subclass of Thread, you would simply perform:
new MyTask().start();
With an implementation of Runnable, you would do this:
new Thread(new MyTask()).start();
This assumes you don't need to monitor the threads, won't be sending any messages to your tasks or any such thing. If that were the case, you would need to tuck away those returns to new MyTask() for later access.
In order to launch two threads simultaneously, you would have something along the lines of:
new MyTask().start();
new MyOtherTask().start();
Now it is perfectly possible that MyTask() would complete before MyOtherTask() managed to start in which case it wouldn't appear as if you had actually had multiple threads running, but for non-trivial tasks, the two will likely overlap. And of course, in a game, these tasks would likely be launched in response to user input, which means that you wouldn't have any control over when or in what order they executed.
Anyhow, it's as simple as that. You should also consider following the Java Threading trail which shows a simple example of using multiple threads. You can find it at:
http://java.sun.com/docs/books/tutorial/essential/threads/index.html
Regards,
Lynn
Similar Messages
-
Help with running multiple instances of conky in openbox.
A few days ago I installed openbox after uninstalling KDE- due to it being just to heavy on my old laptop. I have everything setup now apart from conky, which is actually setup (I have it customized it to my liking). But if i try to run all my conky's at startup- they either flicker alot if i have "own_window" set to "no". This enables me to click the desktop without the openbox menu being hidden under a conky. But if i set it to "yes" it fixes the flickering issue, but then i cannot click on the desktop where the conky's are. And due to having a small screen, when opening the openbox menu it gets hidden by a conky window. I have searched the forums but i cannot seem to find an answer to this. If you know how to fix this please respond as quickly as possible...
Thanks...
Also i have another question, i have installed a gtk theme for my setup and all icons have changed. But because by default you don't have media folders eg. Documents, Pictures. I had to create them, so they have stayed as the default gtk theme icon for a folder. How would i go about making them use the documents icon etc.
Last edited by matt101 (2010-09-04 16:16:19)I don't want to set own_window to yes unless there is a workaround for displaying the openbox menu over the top of conky when own_window is set to yes. Also double_buffer is already set to yes with the own_window set to no.
EDIT: I can set own_window to no and there will be no flickering and i can click on the conky and it will bring up my openbox menu. But this only works with one instance of conky. If i run a second instance of conky it starts flickering and the amount of flickering increases the more instances of conky i'm running.
Last edited by matt101 (2010-09-04 16:44:48) -
Help with understanding multi-threaded code
Hi Everyone,
I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
public class SetPriority extends Object
private static Runnable makeRunnable()
Runnable r = new Runnable()
public void run()
for(int i=0; i<5; i++)
Thread t = Thread.currentThread();
System.out.println("in run() - priority=" + t.getPriority() +
", name=" + t.getName());
try{
Thread.sleep(2000);
}catch(InterruptedException x){
//ignore
return r;
public static void main(String[] args)
Thread threadA = new Thread(makeRunnable(), "threadA");
threadA.setPriority(8);
threadA.start();
Thread threadB = new Thread(makeRunnable(), "threadB");
threadB.setPriority(2);
threadB.start();
Runnable r = new Runnable()
public void run()
Thread threadC = new Thread(makeRunnable(), "threadC");
threadC.start();
Thread threadD = new Thread(r, "threadD");
threadD.setPriority(7);
threadD.start();
try{
Thread.sleep(3000);
}catch(InterruptedException x){
//ignore
threadA.setPriority(3);
System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
}My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
Thanks for your time.
Regards
Davo
P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
"private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
public class MyNewClass implements Runnable {
public void run() {
// All the same code inside run()
public class SetPriority {
private static Runnable makeRunnable() {
Runnable r = new MyNewClass();
return r;
// The rest of the original code
}Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
Think about this for a while. In the mean time I'll write up the "static". -
Problem with ioinning multiple Threads
Hi,
I have multiple sub Threads T1, T2, T3.... started by main Thread T. After starting each sub Thread, I stored them in the HashMap. When finish starting all Threads, I want to join each sub Thread to my main Thread.
The problem is when T3 join with T, it hanged forever! Here is my code:
class MyThread extends Thread
private name;
MyThread(String tName)
name = tName;
public void run()
// doing something....
public HashMap startThreads()
HashMap tList = new HashMap();
for (int i=0; i<5; ++i)
String tName = "Thread" + i;
MyThread myT = new MyThread(tName);
myT.start();
tList.put(tName, myT);
public void joinThreads(HashMap tList)
Iterator iter = tList.values().iterator();
while (iter.hasNext())
Thread activeThread = (Thread)iter.next();
if (activeThread.isAlive()) {
System.out.println("Join alive thread " + activeThread.tName);
activeThread.join();
In my method:
... doing s/t
HashMap tMap = startThreads();
joinThreads(tMap);
... doing s/t else (never excecuted!!!)
My purpose is staring multi Threads at the same time and executing some code after they all die.
If I join my sub Thread right after creating it, then the other sub Thread couldn't started until subThread 1 dies!
If I don't join the sub Thread but remove it from the thread Map when it's not alive then my code executed perfectly. I want to apply join method with my mutiple Threads, how ????
Could some one give me a hint? Thanks.Hi,
What I don't understand here is why the main Thread
does not join all the sub Threads ?If you're getting a ConcurrentModificationException while iterating the list of threads, then that's why.
Why main Thread
has to wait for sub Thread 1 to finish before joinning
next sub Threads?It has to join all of the threads. That means it has to wait for all of them to finish. In order to wait for all of the threads it has to wait for the first thread.
I'm 100% sure that my sub Threads in
the threadList are valid and alive since I already
veriffied with other methods.I don't see what that has to do with your problem.
I already set my joinThreads method as synchronized,
how come I still have ConcurrentModificationException?Because the list was modified concurrently.
How can I fix this error?Stop modifying the list concurrently. You haven't posted all of the relevant code, so I can't offer any clues about how to do that. -
How to run multiple Thread using Scheduler's in 1.5
Hi,
I have a scenario, in which I have to run a Thread at every 15 minutes, If the first Thread is not Finished in 15 min then new Thread has to start.
Currently I implemeted with java 1.5 schedulers, but the problem is if my first Thread is taking more than 15 min, then no new Thread is starting.
Following is my Code:
TestAccountingThread accountingThread = new TestAccountingThread();
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10);
scheduler.scheduleAtFixedRate( accountingThread, 0, 60, SECONDS );
Can any one help on this, This is really urgent.
Regards,
Sumanif my first Thread is taking more than 15 min, then no new Thread is startingIf it takes more than 15 min, manually run a new scheduler with initial-delay=0 and shutdown the current one when the current execution is finished --- and repeat this logic in a conditional loop.
Could this be what you want? -
Need help with turning multiple rows into a single row
Hello.
I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
My situation:
I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
select jiraissue.id, pkey, reporter, summary
,changegroup.created change_dt
,dbms_lob.substr(changeitem.newstring,15,1) change_type
,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
from jiraissue
,changeitem, changegroup
,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
where jiraissue.project = 10110
and jiraissue.issuetype = 51
and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
and phaseinfo.issue = jiraissue.id
and changeitem.groupid = changegroup.id
and changegroup.issueid = jiraissue.id
order by jiraissue.id,change_dt
Results:
1 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 9:30:38 AM Open 1
2 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2008-07-16 11:37:02 AM Testing 2
3 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-06-08 9:14:52 AM Closed 3
4 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:37 AM Open 4
5 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:42 AM Open 5
6 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:50 AM Testing 6
7 21191 QCS-91 Error running the Earliest-deadlines flight interface request/response message 2010-09-02 11:29:53 AM Closed 7
8 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-10-03 10:26:21 AM Open 1
9 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2008-11-17 9:39:39 AM Testing 2
10 23234 QCS-208 System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role 2011-02-02 6:18:02 AM Closed 3
11 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2008-09-29 2:44:54 PM Open 1
12 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2010-05-29 4:47:37 PM Blocked 2
13 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:14:57 AM Open 3
14 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:32 AM Testing 4
15 23977 QCS-311 Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks 2011-02-02 6:15:47 AM Closed 5Hi,
Welcome to the forum!
StblJmpr wrote:
... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
CREATE TABLE changegroup
( issueid NUMBER
, created DATE
, id NUMBER
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (21191, TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23234, TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'), 30);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'), 10);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'), 20);
INSERT INTO changegroup (issueid, created, id) VALUES (23977, TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'), 90);
CREATE TABLE changeitem
( groupid NUMBER
, newstring VARCHAR2 (10)
INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
ISSUEID HISTORY
21191 Open (0) >> Testing (692) >> Closed
23234 Open (45) >> Testing (807) >> Closed
23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
"The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
The database is 10.2.0.4That's very important. Always post your version, like you did.
Here's one way to get those results from that data:
WITH got_order_row AS
SELECT cg.issueid
, LEAD (cg.created) OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
- cg.created AS days_in_stage
, ROW_NUMBER () OVER ( PARTITION BY cg.issueid
ORDER BY cg.created
) AS order_row
, ci.newstring AS change_type
FROM changegroup cg
JOIN changeitem ci ON cg.id = ci.groupid
WHERE ci.newstring IN ( 'Blocked'
, 'Closed'
, 'Testing'
, 'Open'
-- AND ... -- any other filtering goes here
SELECT issueid
, SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
WHEN CONNECT_BY_ISLEAF = 0
THEN ' ('
|| ROUND (days_in_stage)
|| ')'
END
, ' >> '
, 5
) AS history
FROM got_order_row
WHERE CONNECT_BY_ISLEAF = 1
START WITH order_row = 1
CONNECT BY order_row = PRIOR order_row + 1
AND issueid = PRIOR issueid
AND PRIOR change_type != 'Closed'
ORDER BY issueid
;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary. -
Help with query - multiple where in grouped column
4 columns in table named RRID1
RRI_ID
USER_ID
PROCESS_TYPE
FUNCTION
not sure how to make this query.
Need to pull all RRI_ID's where PROCESSTYPE ='INFO' and PROCESSTYPE ='RESOLUTION'
for that RRI_ID.
so same user, same RRI_ID and 2 process records, 1 INFO and 1 RESOLUTION
so not if there is duplicate info, just if there is info and resolution.
This is what some of data looks like..
PROCESSTYPE|USER_ID|FUNCTION|RRI_ID
INFO 3668 30287 817
INFO 3748 30287 817
INFO 4714 30287 817
INFO 4875 30287 817
INFO 4882 30287 817
INFO 4885 30287 817
INFO 3748 30288 818
INFO 4714 30288 818
INFO 4716 30288 818
INFO 4882 30288 818
INFO 4885 30288 818
INFO 3668 30289 819
INFO 4716 30289 819
INFO 4875 30289 819
INFO 4882 30289 819
INFO 4885 30289 819
INFO 3668 30290 820
INFO 4716 30290 820
INFO 4875 30290 820
INFO 4882 30290 820
INFO 4885 30290 820
INFO 3668 30291 821
INFO 4714 30291 821
INFO 4716 30291 821
INFO 4875 30291 821
INFO 4882 30291 821you will have a stroke before you hit 40That's not the point, but thanks for your concern and you'll probably end up having a stroke sooner than me if you keep asking questions this way ;)
Point is: stick to your original thread/question, keep it all together, be complete, instead of reposting and starting all over again.
It's confusing when you start a new thread, while the context of your old thread matters.
While Blu seemed to be correct, you changed the question in your previous thread after his answer and started a new one, with the same 'data'.
Hence me being a 'nit-picker', because by starting multiple threads:
- you'll get the right answer slower, maybe much slower
- we're assuming things that might be out of context, given your previous thread
etc. -
I can't get bonjour to run on my computer. I have tried uninstalling, installing the previous version and downloading bonjour for windows from apple.The service starts normally and is running but the IE plugin shows "bonjour service not available", running the printing wizard shows the same. I ran the dns-sd which shows
c:\>dns-sd -V
DNSServiceGetProperty failed -65537
c:\>dns-sd -I
Registering Service Test.testtxt.tcp.local.
DNSService call failed -65537
I have itunes 8 installed, haven't found the need to use bonjour before so would usually uninstall it. Don't know much about bonjour, tried searching the forums but couldn't come up with anything. Can anyone help with this?I get into the same situation consistently after switching the network connection from Ethernet LAN to Wireless LAN. The only fix I know of is to restart the PC.
-
Help with using multiple hard drives
Is there a way to install the OS on an "external" (expresscard SSD) drive, but have all of the library and data files on the primary hard disk? I LOVE the speed on my SSD, but it's a pain finding stuff now. Is this something a RAID configuration could help with?
mwmmartin wrote:
I have a 1 TB hard drive; but I have a 500GB and 250GB usb external hard drives.
Wouldn't it be cool if I could make the two external hard drives a RAID drive and use Time Machine to use all the 750GB of external memory to do my backups???
You can, but I would +*strongly recommend against+* it. See +Concatenated RAID+ in the Help for Disk Utility.
There are several potential problems:
Depending on how much data is on your 1 TB drive, 750 GB may not be enough to back it up. See #1 in Time Machine - Frequently Asked Questions (or use the link in *User Tips* at the top of this forum).
To set up a +Concatenated RAID+ set, both drives will be erased.
When (not if) either drive fails, you'll lose all the data on both.
Both drives must be connected any time you do a backup or want to browse your backups.
Especially with USB, if one drive wakes from sleep, or spins up, quickly enough, but the other one doesn't, the backup may fail and/or your backups may be corrupted.
For now, it looks like my only solution is to go buy a bigger external hard drive and spend more money,,,
That's your best solution +*by far.+* Anything else is taking a large risk with your backups. -
Need Help with running expect script on MAC OS
Hi Guys,
I'm having an issue with running an expect script on my Mac Mini with Mac OS x 10.7.5. I think the script is correct but the not sure why its not working.
The script is as below and also teh error from Xtern or terminal when i try to run it.
#!/usr/bin/expect
set telnetAddr "172.22.22.254"
set telnetAddr1 "172.22.22.252"
set username "ww"
set passwords "ww"
set enablepassword "ww"
spawn telnet $telnetAddr
expect "Username: "
send "username\r"
expect "Password: "
send "$passwords\r"
expect "Orange-ISRGW>"
send "enable\r"
expect "Password: "
send "$enablepassword\r"
expect "Orange-ISRGW#"
send "sh flash\r"
expect "Orange-ISRGW#"
send "delete flash:c1140-k9w7-tar.default.JAR\r"
expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
send "\r"
expect "Orange-ISRGW#"
send "exit/r"
interact
here is what happens when i try to run it. This is just a test script before i re-write it to do what i intened to use it for.
sh-3.2# ls -al Text-Script.txt
-rwxrwxrwx@ 1 root wheel 592 Dec 6 08:36 Text-Script.txt
sh-3.2# more Text-Script.txt
#/!/usr/bin/expect -f
set telnetAddr "172.22.22.254"
set username "ww"
set passwords "ww"
set enablepassword "ww"
spawn telnet $telnetAddr
expect "Username: "
send "username\r"
expect "Password: "
send "$passwords\r"
expect "Orange-ISRGW>"
send "enable\r"
expect "Password: "
send "$enablepassword\r"
expect "Orange-ISRGW#"
send "term length 0\r"
expect "Orange-ISRGW#"
send "sh flash\r"
expect "Orange-ISRGW#"
send "delete flash:c1140-k9w7-tar.default.JAR\r"
expect "Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]"
send "\r"
expect "Orange-ISRGW#"
send "exit/r"
sh-3.2#
sh-3.2# pwd
/usr/bin
sh-3.2# Text-Script.txt
/usr/bin/Text-Script.txt: line 8: spawn: command not found
couldn't read file "Username: ": no such file or directory
/usr/bin/Text-Script.txt: line 10: send: command not found
": no such file or directory:
/usr/bin/Text-Script.txt: line 12: send: command not found
": no such file or directorySRGW>
/usr/bin/Text-Script.txt: line 14: send: command not found
couldn't read file "Password: ": no such file or directory
/usr/bin/Text-Script.txt: line 16: send: command not found
": no such file or directorySRGW#
/usr/bin/Text-Script.txt: line 18: send: command not found
": no such file or directorySRGW#
/usr/bin/Text-Script.txt: line 20: send: command not found
": no such file or directorySRGW#
/usr/bin/Text-Script.txt: line 22: send: command not found
": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
/usr/bin/Text-Script.txt: line 24: send: command not found
": no such file or directorySRGW#
/usr/bin/Text-Script.txt: line 26: send: command not found
sh-3.2#
sh-3.2#
sh-3.2# ./Text-Script.txt
./Text-Script.txt: line 8: spawn: command not found
couldn't read file "Username: ": no such file or directory
./Text-Script.txt: line 10: send: command not found
": no such file or directory:
./Text-Script.txt: line 12: send: command not found
": no such file or directorySRGW>
./Text-Script.txt: line 14: send: command not found
couldn't read file "Password: ": no such file or directory
./Text-Script.txt: line 16: send: command not found
": no such file or directorySRGW#
./Text-Script.txt: line 18: send: command not found
": no such file or directorySRGW#
./Text-Script.txt: line 20: send: command not found
": no such file or directorySRGW#
./Text-Script.txt: line 22: send: command not found
": no such file or directorylash:/c1140-k9w7-tar.default.JAR? [confirm]
./Text-Script.txt: line 24: send: command not found
": no such file or directorySRGW#
./Text-Script.txt: line 26: send: command not found
sh-3.2#Works like a Charm after making the change suggested ..
macminiserver:ExpectScript Tola$ more Text-Script.txt
#! /usr/bin/expect -f
set telnetAddr "172.22.22.254"
set username "ww"
set passwords "ww"
set enablepassword "ww"
spawn telnet $telnetAddr
expect "Username: "
send "$username\r"
expect "Password: "
send "$passwords\r"
expect "Orange-ISRGW>"
send "enable\r"
expect "Password: "
send "$enablepassword\r"
expect "Orange-ISRGW#"
send "term length 0\r"
expect "Orange-ISRGW#"
send "sh flash\r"
expect "Orange-ISRGW#"
send "delete flash:c1140-k9w7-tar.default.JAR\r"
send "\r"
expect "Orange-ISRGW#"
send "sh flash\r"
interact
macminiserver:ExpectScript Tola$ ./Text-Script.txt
spawn telnet 172.22.22.254
Trying 172.22.22.254...
Connected to 172.22.22.254.
Escape character is '^]'.
User Access Verification
Username: ww
Password:
Orange-ISRGW>enable
Password:
Orange-ISRGW#term length 0
Orange-ISRGW#sh flash
-#- --length-- -----date/time------ path
2 1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
3 63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
5 67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
124751872 bytes available (131600384 bytes used)
Orange-ISRGW#delete flash:c1140-k9w7-tar.default.JAR
Delete flash:/c1140-k9w7-tar.default.JAR? [confirm]
%Error deleting flash:/c1140-k9w7-tar.default.JAR (File not found)
Orange-ISRGW#sh flash
-#- --length-- -----date/time------ path
2 1440 Oct 24 2013 11:23:26 -07:00 vlan.dat
3 63714548 May 3 2010 11:49:40 -07:00 c2800nm-adventerprisek9_ivs_li-mz.151-1.T.bin
5 67871024 Nov 9 2012 19:05:24 -08:00 c2800nm-adventerprisek9-mz.151-4.M5.bin
124751872 bytes available (131600384 bytes used)
Orange-ISRGW# -
Help with running iWeb on multiple computers and find the current site
I have two Macs and MobileMe. I have usually run iWeb on the laptop and have my website on it. I thought I saved the site in MobileMe. When I go to the desktop and open iWeb it opens up an old version of my site. I search for Domain and none of the options are the current site. On my laptop (the current iWeb version) I opened MobileMe's iDisk and tried a couple of the "Domains" that live on it and none of them are the current version. Now, I can't even get my laptop to open the one I had opened a few moments ago beacuse I can't find the newest domain. So, where is my current domain/ I can't find it.
I do have a folder on iDisk called "Sites" that contains the HTML files and folders of my current site but I can't seem to get this to open in iWeb. But, this folder does contain the current version but none of the Domain files I have opened refer to these I guess.
What should I do?
Guy
PS I am running the latest iWeb on both computersWelcome to the Apple Discussions. As you know for both of you to edit and update the web site both of you must be using the same version of iWeb and working on the same Domain.sites2 file.
See MacWorld's online article Managing an iWeb site from multiple Macs. However, there are a couple of caveats: 1 - only one can be editing and uploading at a time; 2 - allow plenty of time for Dropbox to update all copies of the domain file.
What I would do is when you plan on editing the site copy the domain file that's in your Dropbox as a backup. Do you editing and publish. If something goes wrong you'll have the good domain file that was copied just before you started editing. If the site is small and, thus, the domain file the updating will be better insured. Keep both computers online much of the time so the updates will go thru as soon as they are made.
OT -
Need help with running a Java program on Linux
I am trying to get a Java program to run on a Linux machine. The program is actually meant for a Mac computer. I want to see if someone with Java experience can help me determine what is causing the program to stall. I was successful in getting it installed on my Linux machine and to partially run.
The program is an interface to a database. I get the login screen to appear, but then once I enter my information and hit enter the rest of the program never shows, however, it does appear to connect in the background.
Here is the error when I launch the .jar file from the command screen:
Exception in thread "main" java.lang.IllegalArgumentException: illegal component position
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
I am not a programmer and I am hoping this will make some sense to someone. Any help in resolving this is greatly appreciated!Well, without knowing a little bit about programming, and how to run your debugger, I don't think you're going to fix it. The IllegalArgumentException is saying that some call does not like what it's getting. So you'll have to go in an refactor at least that part of the code.
-
Problem with running multiple servlet in same webapplication with tomcat 3
Hi all,
I am using Tomcat 3.0 as webserver with jdk1.3, Servlet 2.0,
Templates for html file and oracle 8i on UNIX platform.
I have problem with multiple servlet running same webapplication.
There are two servlet used in my application. 1) GenServlet.class
and 2) ServletForPrinting.class
All of my pages go through GenServlet.class which reads some property files
and add header and footer in all pages.
I want reports without header & footer that is not possible through GenServlet in my application.
So I have used another servlet called ServletForPrinting --- just for reading html file.
It is as follow:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletForPrinting extends HttpServlet {
public void service (HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
// set content-type header before accessing the Writer
response.setContentType("text/html");
PrintWriter out = response.getWriter();
File f1 = null;
String report = null;
String path = request.getPathInfo();
try{
String p = "/var/home/latif/proj/webapps/WEB-INF/classes" + path;
System.out.println(p);
f1 = new File(p);
p = null;
if (f1.exists()) {
FileReader fr = new FileReader(f1);
BufferedReader br = new BufferedReader(fr);
report = new String();
while ((report = br.readLine()) != null) {
out.println(report);
}catch(Exception e) {
out.close();
report = null;
path = null;
f1 = null;
} // end class
It works fine and display report properly.
But now Problem is that if report is refreshed many times subsequently,
WebServer will not take any new change in any of java file used in web-application.
It works with the previous class only and not with updated one.
Then I need to touch it. As soon as I touch it, webserver will take updated class file.
Anybody has any idea regarding these situation?
Is there any bug in my ServletForPrinting.java ?
Any solution ????? Please suggest me.
Suggestion from all are invited. That will help me a lot.
Thanks in advance
Deepalee.Llisas wrote:
I solved the problem, I just had to wire the blocks in a sequential way (I still don't know why, but it works).
Feel free to delete this topic.
I would strongly suggest at least reading this tutorial to give you an idea of why your fix worked (or maybe only appeared to work). Myself, I never just throw up my hands and say, "Whatever," and wash my hands of the situation without trying my best to understand just what fixed it. Guranteed you'll run into the same/similar problem and this time your fix won't work.
Please do yourself a favor and try to understand why it is working now, and save yourself (or more likely, the next poor dev to work on this project) some heartache.
Bill
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all. -
In a quest to teach myself all about Java Servlets, I'm currently working my way through The Java Web Services Tutorial. However, I have become stuck as I try the command:
ant build
I recieve this message:
Exception in thread 'main' java.lang.NoClassDefFoundError: and
I don't know what is wrong. I have been throught the setting up steps 3 times and cant find any errors.
What tests can I do to isolate the error?
I really need help on this, I can't continue with learning until ant is working.
Thank-you,
Paul
PS. When I'm checking my PATH variables in XP, I find it very annoying. When editing them, I can only use the very small input box provided. Is there any other way to edit them?crostar:
If you run "java" from the command line, it will use the first java.exe found on the %PATH% variable (win os). Double check that the java.exe doesn't exist earlier in the %PATH%. Also, I've made the mistake where my environment variables aren't up to date because I opened a command window and then changing environment variables via the control panel.
AliaAtreides:
You'll need to post the full exception in order for others to determine what might be wrong. More specifically, we need to see the exception in order to determine what class can't be found.
Also, make sure to set the JAVA_HOME and JWSDP_HOME environment variables. please be careful to note that the examples that came with the java web services dev pack have ant build.xml files that depend upon the jswdp.home variable being set. You'll need to set the variable in either the control panel, or in a separate build.properties file.
Oh, one more thing, veramkovich's example sets JAVA_HOME to point to 1.4.1 whereas i think you're previous posts implied that you had a different path, 1.3.1 -
Help with loading multiple images via LoadVars
Hello everybody.
I need a hand loading multiple images using the LoadVars
method with a text file. I can get it to load 1 image but not
anymore than that. I am aware of other methods like using
components but I am looking for a method where I can access and
change all data from 1 text file (there will be text variable text
within the file aswell to, but I am more concerned with the images
at the moment).
Anyway on to the issue. I have created a much simple .fla
file that outlines my problem.
The movie contains 3 layers:
- top layer contains AS
- middle layer contains an empty movie clip with the
instance name of mcImage1
- bottom layer contains an empy movie clip with the instance
name of mcImage2
The AS layer contains the following code:
imagedata = new LoadVars()
imagedata.load("data.txt")
imagedata.onLoad = function(ok){
if(ok){
mcImage1.loadMovie(this.Image1)
mcImage2.loadMovie(this.Image2)
} else trace("Problem Loading")
In the same folder of my .swf file I have a text file called
data.txt which contains the following
&Image1=image1.gif
&Image2=image2.gif
Also in the same folder of my .swf file I have two images
image1.gif and image2.gif.
When I run the flash the image2.gif is imported correctly.
image1.gif does not appear.
You can download my source files and all images here
http://www.myrealpage.com/projects/var_test/var_test.zip
Any help that can be shed on this problem is much
appreciated.
Thanks
MattGlad to help. It is just that I see so many folks who have
two different parts of a problem smushed together – each
problem isn't so hard on its own, but together they are difficult
to wrap your head around. Always try and break down each step of
the problem and it will help you in the end.
That being said, I'm not quite so sure on this next problem.
I don't do so much timeline stuff along with the Actionscript. I
can get tricky. So this I don't quite have as much of clear mental
picture of what you are describing. But here are some questions
that I would ask – either of myself if I was doing it or of
you.
Is there a stop() on frame one to wait for the
LoadVars.onLoad? Does the onLoad then say to play?
If not, what happens if we get to Frame 10 before the
LoadVars has even finished? That could be a problem.
Remember that the LoadVars object is an actual object that
will exist until it is deleted or removed in various ways. You can
access it at any time after it is loaded. The onLoad event handler
is just that thing you want to happen immediately after it is
loaded.
So my design would probably be.
LoadVars on Frame 1.
Where I am stopped.
In the onLoad handler load the first image and tell the
timeline to play
On frame 10, the LoadVars object will still exist (unless
you've deleted it)
Get the variable out of the LoadVars and load the image.
If you want to check this. Put a stop() in frame 10 and run
it in the testing environment. When it gets to that frame, go to
the debug menu and List Variables. You should see that your
LoadVars object is still there.
Does that answer your question or am I totally missing the
point?
Maybe you are looking for
-
Hello everyone, There are 3 issues I have, as it reads in the title. 1) I am running iTunes on a Win7 64-bit ThinkPad, and iTunes shows up as a 32-bit application in the Task Manager, always. I tried even the complete uninstalling (after removing Bon
-
Does not effect any other websites I've tried to open.
-
Error when exporting from Quicktime
I have been trying to export sound from a sound only .mov file but I am getting the error : Export Controller has stopped working The problem started after I was able to export one file. Anybody know what the problem might be? Any help would be great
-
Searching a string in a table.
Hi, I am using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production. I have a situation where I need to find the number of occurrences of a string that is present in a table having comma separated values. To explain with an ex
-
Adobe Pro 9 Property Bar issue - No Current Selection
I'm using AP9 Extended. For some reason when I click on Ctrl + E the Property Bar will not display. I get a "No current selection" on one of the bars that are activated. It appears that the only way I can get the Property Bar to display is by highlig