 |
 |
Index ‹ java-programmer
|
- Previous
- 2
- 3
- Announcement: PerfectJPattern first release 1.0.0 available ...hi,
After long working hours have been able to finally put together a first
release of PerfectJPattern. The aim of PerfectJPattern is to build a
library of componentized (reusable and context-free) Design Patterns
in Java.
Please visit the home page under: http://perfectjpattern.sourceforge.net
Feedback most welcome!
Best regards,
Giovanni
PS: I still have plenty to work on the documentation again any feedback
with corrections/suggestions will be most welcome.
- 4
- log4j with OpenJMS
Anybody got sample code for sending log4j messages specifically to OpenJMS?
In particular I'd like to do it all programmatically, since I'm working with a fairly complex pre-existing build system and would rather not start introducing too many new properties files. I have a log4j.properties file, but I'm trying to avoid having to create a jndi.properties file.
I stuck this code from OpenJMS in my Logging utility (which wraps log4j):
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
Context context = new InitialContext(properties);
and log4j.properties has a simple:
log4j.myLogger=DEBUG, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName=testtopic
log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory
I keep getting the error "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial" which leads me to believe that my block of code is not storing the InitialContext in a way so that log4j can get at it.
Thanks!
- 4
- Problems in xml parsingHi,
I am using XMLTool.java to convert an xml file into an xml document
and
I am parsing the xml file using Nodelist and Nodes.
NodeList ls = getElementsByTagName("xxx").
Its working fine when I am running my application in windows.
But when I am running the same application in unix, I am getting
exceptions while parsing. Its giving null value and I cannot proceed
further.
Can anybody pls suggest where I am doing wrong?
I appreciate your help.
Regards,
Hari.
- 4
- Code generation aplicationOn Mon, 11 Aug 2003 21:55:14 +0100, Alexandre Cotta Godinho wrote:
> Hello there !
>
> I need some help in increasing productivity. Do anyone knows about a
> code generation tool, as customizable as possible allowing to generate
> from UML dynamic diagrams as well. There is a nicely referenced product
> of name Codagen Architect (www.codagen.com), but it runs on Windows only.
>
> Thank you in advance
>
> Alexandre Cotta Godinho
TogetherJ or Rational Rose.
Both are -1 imo.
-c
- 4
- Hi iam bavaniHi iam bavani
life is the first gift
love is thesecond
understanding is the third
****************************************
htt:"my profile 22 blogs pot.com
**********************************************
username:bavanikumar22
***********************************************
- 4
- repeating program codeI've created a program that calculates real estate commission. The person
inputs the sale amount and then enters a letter which represents a certain
commission rate. It then calculates the commission and displays it. After
the commission amount is displayed i want it to prompt the user for
another transaction. When there are no more transactions i want the
program to display the total amount of the properties entered, and the
total amount of the commissions calcualted. I'm not too sure what to do.
Should i use a while loop? Here is what i have done so far.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;
public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;
// Enter sale price
String salePriceString = JOptionPane.showInputDialog (null,
"Enter sale price",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
salePrice = Double.parseDouble(salePriceString);
// Enter property code (residential, multidwelling or commercial)
String propertyTypeString = JOptionPane.showInputDialog (null,
"Enter property code (residential (R), multidwelling (M) or
commercial(C))",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.equals ("C"))
commissionRate = 0.035;
// Calculate commission
double commission = salePrice * commissionRate;
// Format to keep two digits after the decimal point
commission = (int)(commission * 100) / 100.0;
// Show results
JOptionPane.showMessageDialog(null,
"the commission is" + commission,
"Cakculator Output",
JOptionPane.INFORMATION_MESSAGE);
String transactionString = JOptionPane.showInputDialog (null,
"Would you like to do another transaction (YES or No)",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
while (transactionString.equals ("YES"))
System.exit(0);
}
}
- 5
- Refinement of a Java prog called by PHPAfter listening to everybody's replies, I rephrase my problems as follows:
I modify my program from my client:
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ( "jdbc:mysql://127.0.0.1/" +
dbstr, "root","");
...
after a series of search in the db "dbstr",
I want to return result from the search obtained by this Java program by
simply using System.out.printIn because I tried a C program and printf
simply works.
In order to make sure the java program can be called by PHP successfully, i
place it under the php directory instead of calling
system(java_prog_absolute_path/the_java_prog);
And the error returns from the java "slave" prog to the "master" php prog
is:
the error is:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at
java.net.URLClassLoader$1.run(URLClassLoader.java:200) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at
java.lang.ClassLoader.loadClass(ClassLoader.java:251) at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:169) at
SearchDatabase4.(SearchDatabase4.java:74) at
SearchDatabase4.main(SearchDatabase4.java:344)
And the file SearchDatabase4.java is:
74: Class.forName("com.mysql.jdbc.Driver");
344: new SearchDatabase4(args[0], Double.parseDouble(args[1]),
- 5
- Pre-Populate a Form that nested tagsI have a Struts action form which contains a bean. I am trying to
display a bean retrieved from the database in this form using the
nested tag. Can anyone help me? I continue to get an error message
see end for stack trace.
Struts config
<form-bean name="newBean" type="com.NewForm" />
.....
<action path="/new-action" type="com.NewAction"
name="newBean" scope="session">
<forward name="blah" path="/New.jsp"/>
</action>
Bean
public class Program implements Serializable {
private int prg_pk;
private String prg_prog_name = null;
private Set courses;
getters()/setters()
Form
public class NewForm extends ActionForm {
private Program program;
/**
* Returns the program.
* @return Program
*/
public Program getTheProgram() {
return program;
}
/**
* Sets the program.
* @param program The program to set
*/
public void setTheProgram(Program program) {
this.program = program;
}
public void reset(ActionMapping mapping, HttpServletRequest
request) {
HttpSession session = request.getSession();
setTheProgram((Program) session.getAttribute("PROGRAM"));
}
}
JSP
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<nested:form action="/new-action.do">
<nested:nest property="program" >
<nested:write property="prg_prog_name"/>
</nested:nest>
</nested:form>
Stack Trace
java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:315)
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:303)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:663)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:710)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
at org.apache.struts.taglib.nested.bean.NestedWriteTag.doStartTag(Unknown
Source)
at org.apache.jsp.New$jsp._jspService(New$jsp.java:114)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479)
- 5
- Swing Applet, JDBC and MySQL Connector ConfusionI believe your applet must be run from a signed jar, and the MySQL database
must also be resident on the same server as the applet. I'm not 100% sure of
this in your case....but I am 99% sure. -Ike
- 5
- Overheads involved in repeated acces to a database using JDBCI have an application that inserts words and their associated values
into a hashtable. If the word already exists in the hashtable, the
value associated with the word is increased in the hashtable. When the
hashtable is complete, I write its contents into a simple, two-column
table in a singer-user database using jdbc.I'm using MS Access at the
moment because my database doesn't need to support multiple -users or
very complex queries.
-Would I be better to take the hashtable out of the equation all
together? (i.e. read, write and update the values in the database as I
go along).
-Do you know if there is much overhead involved in contacting a
database in this way, as I would need to do it about 4,000 times?
I'm not sure how jdbc works.
-Can you alter the result set repeatedly and do a mass write to the
database at the end?
-Would another type of database suit my needs better?
Thanks in advance
~M
- 5
- grant execute file permission to a JSP? I'm trying to run an external command from a JSP and instead get
the exception:
java.security.AccessControlException: access denied (java.io.FilePermission /usr/bin/killall execute)
which seems clear enough. (The code runs and works from within a
console application.)
The OS is Linux and the application server is the one that
installs with the J2EE sdk from Sun. It is installed within my
home directory and runs under my user ID exposing deployed JSPs
at http://localhost:8080/
I've added the following code to both my ~/.java.policy file and
the ${java.home}/jdk/jre/lib/security/java.policy file:
grant codeBase "http://localhost:8080/-" {
permission java.io.FilePermission "/usr/bin/killall", "execute";
permission java.security.AllPermission;
};
Neither of the entries in either of the files makes any
difference. The only change I've made that has any affect at all
is to change the command from 'killall ...' to '/usr/bin/killall
...' which changed the file reference in the exception from "<<ALL
FILES>>" to "/usr/bin/killall".
Each time I made a change in the policy files, I restarted the
application server to make sure it was using the new file contents.
I'm clearly overlooking something or have something wrong. Any
suggestions on how to resolve this would be most welcomed!
thanks,
hank
- 13
- Failed to load or instantiate TagExtraInfo classI am using struts-1.3.8 tiles together with Spring, now I wanted to
implement my own custom tag. Following a book example, I wrote a
TagHandler that extends "SimpleTagSupport". Eclipse told me I needed
to import the jsp-api.2.0.jar from tomcat, so I did.
However, this always results in the error:
org.apache.jasper.JasperException: /WEB-INF/jsp/myjsp.jsp(1,1) Unable
to read TLD "META-INF/tld/struts-tiles.tld" from JAR file
"file:myFileLocation": org.apache.jasper.JasperException: Failed to
load or instantiate TagExtraInfo class:
org.apache.struts.tiles.taglib.UseAttributeTei
I did some research on the web, there it's said not to include the jsp-
api.2.0.jar (but not why not to), and yes, this solves the problem -
but how can I implement my Tag handler without using this jar file?
Eclipse doesn't find the required classes otherwise...
Thanks in advance,
Christine
- 14
- executing data needs mprotect with PROT_EXECThis is a multi-part message in MIME format.
I've been trying to run some FreeBSD4 packages
inside a jail on a FreeBSD6 / amd64 box; and I've
hit a problem with ports/jdk.
A couple of places the VM uses an array of
integers, puts code in it, and executes it.
This doesn't work on machines where the CPU
honors the PROT_EXEC settings; this can be
different on different machines (depending on
BIOS settings probably).
The right fix is to call mprotect() from jdk to allow
execution of the memory in question, something like this:
--- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb
14 21:12:46 2006
+++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb
15 16:30:49 2006
@@ -561,6 +562,9 @@
}
#else
static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void),
code_template);
+
+ ::mprotect((void *)code_template, sizeof(code_template),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
fixcw();
--- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11
03:40:14 2003
+++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14
23:34:40 2006
@@ -9,6 +9,8 @@
# include "incls/_precompiled.incl"
# include "incls/_vm_version_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
int VM_Version::_cpu;
int VM_Version::_cpuFeatures;
@@ -145,6 +147,10 @@
ResourceMark rm;
// Making this stub must be FIRST use of assembler
CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode));
+
+ ::mprotect((void *)stubCode, sizeof(stubCode),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
+
VM_Version_StubGenerator g(c);
getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t,
g.generate_getPsrInfo());
patches also attached in case the mail client mangles them :-)
- Arne H. J.
- 14
- IP-HOSTNAME Conversion ProblemHi,
I found many utilities in the web or rather the internet to resolve ip
address and host names , i took this example
host name : mp3.box.sk whose IP was resolved to be 69.31.81.51
now i took the same ip and tried to resolve the host name, for my
surprise i found that to be
colo-69-31-81-51.pilosoft.com which is not mp3.box.sk for sure, can
anyone explain as to why this problem is caused?
|
| Author |
Message |
Flex

|
Posted: 2005-3-25 17:21:00 |
Top |
java-programmer, improve J2EE performance
I have installed on my computer Sun J2EE server to use IMQ.
Normally after boot I digit :
./[path]/bin/asadmin start-domain domain1
but the performance aren't good , because I use an application with (more
or less) some hundreds msg/minute.
How Can I improve this server's performance ?
I can start this server on another runlevel or I can allocate to him more
resources ?
--
Ciao Flex
________________________________________________
Chi sa ascoltare non solo e' simpatico a tutti ,
ma prima o poi finisce con l'imparare qualcosa
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- parallel port and javai want to communicate with parallel port of the computer , i am using
windows xp service pack 2, can any body help me?
- 2
- Problem in configuring eclipse to point to a jdk instead of jreHi all,
I am trying to use eclipse as the IDE with the m2eclipse plugin; I
have created the project structure using maven2 in the command line;
then I create the eclipse project files with "mvn eclipse:eclipse"
When I import the project into eclipse... the maven2 builder has
errors such as "tools.jar is missing" or "1 artifact is missing"
I searched a few forumns and found that eclipse didn't use JDK but JRE
to compile classes and tools.jar is only available under JDK....
So my question is how to solve this problem? I've tried to create
another JRE to point to JDK folder... but failed
PS. I could build the whole project under command line "mvn clean
compile"
I'm using a Windows XP Professional OS; maven 2.0.7; jdk 1.5.0.12;
eclipse Europa
>From Jason (Kusanagihk)
- 3
- doModalHello.
How can I open a JFrame as a modal dialog box ?
Thanks :)
- 4
- Latte Diablo JRE 1.3.1 binary package on FreeBSD4.7Hi All,
I was wondering if anyone else at Imeme has had any success with getting
JDK /usr/ports/java/jdk13 working on their jail.
Also if anyone on the freebsd-java list has any experience getting jdk13
working on FreeBSD 4.7 I would much appreciate any help.
The build command I am running in /usr/ports/java/jdk13 is
make build FORCE_PKG_REGISTER=1 WITHOUT_X11=1
I am not sure if I need (or if it does anything) the WITHOUT_X11=1 but I
know that we aren't running X11 and have used that on ports before so
thought I would try it.
make goes off and does a lot of stuff and ends with the following:
---------------------------------
gmake[3]: *** No rule to make target
`../../../build/bsd-i386/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider',
needed by `copy-files'. Stop.
gmake[3]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[2]: *** [optimized] Error 2
gmake[2]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[1]: *** [all] Error 1
gmake[1]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax'
gmake: *** [all] Error 1
*** Error code 2
Stop in /usr/ports/java/jdk13.
--------------------------------
I tried a make clean and then the same command just in case and same thing.
This looks like something to do with sound. Seeing as we don't actually
need sound to work I wonder if there is a way to skip that. Anyone know
where I could look?
Cheers,
Pete
--
Peter Simmons
Senior Consultant BCMPweb Limited
M:+64 21 676 909 F:+64 9 374 4250
email***@***.com http://www.bcmpweb.com
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 5
- Novell Tutorial: Building_A_Modern_Web_Application
http://developer.novell.com/wiki/index.php/Building_A_Modern_Web_Application
"As companies become more reliant on the Web, it is increasingly
important to deliver applications using the browsers that have the same
functionality as rich clients. Programming applications using HTML,
cascading style sheets (CSS), and Asynchronous JavaScript and XML (AJAX)
on the front end and using a Linux, Apache, MySQL, and PHP (LAMP) stack
on the back end helps to fill this gap."
"Everything presented in this article was done on a SUSE 10.0
workstation using the following versions of software:
* Apache 2.0.54-10.3
* MySQL 4.1.13-3
* PHP 4.4.0-6.8
* Firefox 1.5 "
--
The Texeme Construct
http://you-read-it-here-first.com
- 6
- Dangerous code up for peer reviewHi,
looking for some advice,
I have a database for addresses coded in java.
to print the addresses, a jframe is popped up that holds various report
layouts.
the user chooses a layout then this launches Jasper reports.
basically when the user presses the print button is the current screen is
hidden.
then a report layout screen is popped up, ( this cannot be a modal, as it
would sit on top of any screen generated by jreports)
the problem was , as the report layout screen was not a modal , the code was
returning directly back to the "mother screen" ,and un-hiding it.
to get round this problem I have implemented a couple of linked lists, where
the mother screens sets up a separate thread and then calls the child
screens to get their status.
here is a small section of the jasper report compiler
private void CancelButton_actionPerformed(ActionEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
this.setVisible(false);
}
private void this_windowClosed(WindowEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
//cancel the import
//here we need to exit the screen
this.dispose();
}
......
here is the signalling routine.
public void sendStatus(int currentStatus) {
String aa = String.valueOf(currentStatus);
addWork(aa);
}
public synchronized void addWork(Object o) {
queue.addLast(o);
notify();
}
//it is possible that the program could get hung here
//if the normal flow is interrupted
public synchronized int getWork() throws InterruptedException {
while (queue.isEmpty()) {
wait();
}
return Integer.parseInt((String) queue.removeFirst());
}
to stop the mother screen from being shown i have
r = new Runnable() {
public void run() {
try {
call the layoutscreen & jasper reports here
ReportWriter doReport = new ReportWriter(params,
my_vars.dbconn, errorlogger);
while (statusFlag != CMD_SIGNAL_GOOD_EXIT) {
statusFlag = doReport.getWork();
}
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
} finally {
show();
repaint(); //refresh the screen
}
}
};
new Thread(r).start();
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
}
i'm not really happy with the safety of the code, even though the exceptions
and all exits from the child screen are covered, and after testing the mother
screen is always shown again, even after an error.
- 7
- C++ to Java aplet, need help to understand.Hi,
I have a c++ application that uses Direct X to get images from my webcam.
Now I want to stream images from my application to the internet.
I just want to make sure I understand how a java applet would, (should?),
work.
When the user load the page where the java applet is located, the applet
makes a request to my machine for an image.
The applet then displays the image at a certain location in the page.
So a java applet does not really 'stream' videos, instead it makes a request
for an image every 'x' seconds.
All the applet needs is address and port where my application is located,
(and the name of the function that will return the frame).
Sadly I have no knowledge of Java, (well a little maybe).
Where could I find some code for an applet that would make a request to my
application.
How can a java applet make a request to a win 32 c++ application?
And what would the code look like in an html page?
Many thanks in advance for any help/code.
Simon
- 8
- Cock Starved Housewife Gets Fucked With Her Legs Spread Wide Just few link on some movies...
All just for you...
Download
>>>>> http://download-video.12w.net
>>>>> http://world-sex.urllogs.com
>>>>> http://video-sex.12w.net
CLICK FREE DOWNLOAD VIDEO PORN...
L
I
C
K
T
O
W
A
T
C
H
V
I
D
E
O
P
O
R
N
D
O
W
N
L
O
A
D
F
R
E
E
.
.
.
W
E
L
C
O
M
T
O
M
O
V
I
E
S
P
O
R
N
D
O
W
N
L
O
A
D
.
.
.
- 9
- avoid lot of try/catch blocksemail***@***.com, 08.02.2008 12:17:
> Hello,
>
> Is it possible in Java to write a "global" try/catch block which will
> monitor exceptions in all threads?
> In my application I have 20 JFrames and 10 methods in it, I just can't
> write 200 try/catches :)
> I've researched for several hours but haven't found any answer.
>
> Thank you.
Maybe setDefaultUncaughtExceptionHandler() is what you are looking for:
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)>
Thomas
- 10
- How to identify a website's scale?On 8 May, 19:15, Roedy Green <email***@***.com> wrote:
> When I was in grade 5, our teacher Miss Chapman asked me if a
> hippopotamus was "big". I replied "compared to what? It is big
> compared to a dog but small compared to an elephant."
Hippopotamus size conjugates as an irregular comparison, based on the
square root of the distance between the two of you, divided by the top
speed of any vehicle that you're in. If you're within sight, in any
sort of small boat, then they're big scary f*ckers, especially the
little ones with the pushy parents.
For an animal whose usual reaction to anything startling is to fling
dung at it with its tail,
the only surprise is that they haven't yet acquired Usenet access.
- 11
- 12
- Running java programs from class filesNigel Wade wrote:
> Knute Johnson wrote:
>
>> Babu Kalakrishnan wrote:
>>> Knute Johnson wrote:
>>>> Babu Kalakrishnan wrote:
>>>>
>>>>> Knute Johnson wrote:
>>>>>
>>>>>> Oliver Wong wrote:
>>>>>>
>>>>>>> "Knute Johnson" <email***@***.com> wrote in message
>>>>>>> news:qe%Ig.2$email***@***.com...
>>>>>>>
>>>>>>>> Babu Kalakrishnan wrote:
>>>>>>>>
>>>>>>>>> The commandline for the above example in that case would be :
>>>>>>>>>
>>>>>>>>> java -classpath /xyz/abc MyPackage.MyClass
>>>>>>>>>
>>>>>>>> That doesn't work for me although I have seen reference to it before
>>>>>>>> like that. Could it be that it doesn't work on Windows like that?
>>>>>>> It works for me on WinXP SP2:
>>>>>>>
>>>>>>> java -cp "D:\Oliver's Documents\Workspace\Test\bin" D
>>>>>>>
>>>>>>> to run a class called "D" with no package whose classfile is in
>>>>>>> "D:\Oliver's Documents\Workspace\Test\bin"
>>>>>>>
>>>>>>> - Oliver
>>>>>> That does for me too. But put it in a package and it won't.
>>>>>>
>>>>> Interesting - Seems to work for me even with classes within a package -
>>>>>
>>>>> Running TCPServer.class in package test :
>>>>>
>>>>> java -classpath "C;\Documents and
>>>>> Settings\Babu\workspace\TestServer\classes" test.TCPServer
>>>>> Main: Listening for connections on port 2345
>>>>>
>>>>> Testing on XP Home SP2
>>>>>
>>>>> BK
>>>>>
>>>> package test;
>>>>
>>>> public class Test {
>>>> public static void main(String[] args) {
>>>> System.out.println("It works!");
>>>> }
>>>> }
>>>>
>>>> C:\>javac test/Test.java
>>>>
>>> I'd assume that you now have Test.java and Test.class inside C:\test.
>>>
>>>> C:\>java test.Test
>>>> It works!
>>>>
>>> OK - here the default classpath assumed by the JVM is "." (which is
>>> "C:\"), so it works
>>>
>>>> C:\>cd test
>>>>
>>>> C:\test>java -cp "C:\test" test.Test
>>>> Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
>>>>
>>> Your commandline here should be :
>>>
>>> java -cp "C:\" test.Test
>>>
>>> because the classpath is to be set to the root of the package hierarchy
>>> - which is C:\ in your case.
>>>
>>> With the commandline you used, the class file is expected to be
>>> C:\test\test\Test.class
>>>
>>>
>>> BK
>> Thank you so much guys, this has confused the s**t out of me for years.
>> I think the most confusing part is the root business.
>>
>> So now that you solved that one, show me how to use a jar library on the
>> command line when I run a java program. I can make it compile but I
>> can't make it run. I can get it to work if I put the jar file in the
>> Class-Path: line in the manifest and put the jar file in the same
>> directory as the program jar file but not from the command line.
>>
>
> You can't. It is specifically mentioned in the java man page. When running a jar
> with the java -jar command syntax, the -cp flag is ignored. The jar file is the
> sole definition of the classpath.
Well that's a relief. At least I know now that I'm not going completely
nuts.
> If your executable jar requires classes from other jars, those jars must be
> added to the Class-Path: section of the executable jar's manifest. To further
> annoy you the paths in Class-Path: should be relative paths (although absolute
> paths do work, at least on Linux). I'm not surprised you're confused, you're
> not the only one. I suppose it does offer some measure of security in that a
> user of your application can't change the classpath to inject their own jar's
> to intercept private information from within the application. Although there's
> nothing to stop them unpacking the jar, and re-packaging it with a different
> manifest. So what the purpose really is, other than to annoy and confuse,
> escapes me.
>
Thanks very much Nigel.
--
Knute Johnson
email s/nospam/knute/
- 13
- Confused about referencing info stored in a JFrame
I've tried to develop several JFrame programs in the past and it
always drives me crazy because I can't figure out how to set Classes
I've developed, which aren't Components, but are critical to storing
information necessary for the program to operate, so that they can be
seen by components inside the frame. I'm not very knowledgable about
the structure and coding of Swing/AWT programs, but I understand the
princepals of passing data between methods and classes, and it is very
frustrating to me that I cannot find an easy way (or even a working
way at this point) to reference the info with my program the way I
need to.
To illustrate my question with a real example, I'm trying to write a
program which allows employees at my job to easily receive products
from deliveries by scanning the barcode on the product or putting in
the supplier code on the invoice.
The program needs to be able to extract product info from the database
(to match the scanned barcode and to give the receiver visual
verification that the info in the system is correct), and it needs to
be able to match the product with the vendor, and thus the vendor
codes, which go with the invoice.
I've connected my first draft/test program to the database using a
class I call dbInfo. This class stores the connection information
specific to our database, and also acts as a container/manager for
other classes which populate arraylists such as VendorList, BrandList,
and lists for any other info which is tied to a primary key in the
database and might change during the use of the program (this way in
the info in the form can be refreshed by simply using one dbInfo
method).
My dbInfo class populates all its info into the appropriate lists
correctly. I cannot, however, get my components to see this info.
For example, I have a VendorBox, which is a JComboBox that selects the
vendor for the invoice.
My original vendorBox grabbed its vendor information directly from the
database by storing its own JDBC info and generating the SQL statement
itself. This worked fine, but is not very modular, I had to add code
to every other component that dealt with this info which would to
reference the specific VendorBox on that JFrame form. If I could get
the components to see the dbInfo for the form, I could just store the
reference to VendorBox as dbInfo.invoiceVendor and any other component
could have easy access to it by simply knowing where dbInfo was.
Long explanations can be hard to read, so here's a basic diagram
------------------------------
JFrame
|
}Components
| }VendorBox ( a ComboBox which selects the
| vendor to receive from )
|
}dbInfo (not a component)
}VendorList
------------------------------
My Question: How to I get VendorBox to see VendorList (or dbInfo for
that matter)?
------------------------------
*Note: I'm using Netbeans 5.5, which doesn't allow me to edit the
component initialisation proccess inline. I think I might be able to
do this using the properties window, but I haven't had any luck
getting this to work*
What I've tried:
Just putting it in based on its name and location:
1) A direct reference - using a setdbInfo() method, which sets the
dbInfo equal to JFrameName.dbInfoVariableName. Netbeans gives me a
variable (or symbol or something of the like) not found.
2) The Netbeans property window - because I have setdbInfo() and
getdbInfo() fields in my VendorBox class, Netbeans shows dbInfo in the
property window. Trying to edit this property gives me a form which
among other things says 'form connection mode' and has options like
'from property' and 'from method'. None of the options have any
options to select within them, which I think is because i need to do
something to set up the form connections, but I'm not sure and my own
personal searches have not presented me with useful information.
At this point I thought I'd try to make a finddbInfo class, which
would just find the dbInfo class by crawling its way out
3) Introspection - When I read the description of this I sighed
relief, I thought it would show me the class that my VendorBox was
inside, but as far as I can tell it only shows you the class
inheritance information. I tried all the getxxx() commands netbeans
offered for code completion, but all I got back was info from the
classes my vendorBox was built on or null.
4) VendorBox.getParent() - combined with introspection, I used this to
progress a Class from displaying info about my vendorBox to info about
its containing panels, when I progressed to the outmost panel,
however, instead of getting the JFrame info on the next entry, I got
null.
At this point I cried, cut myself, and poured the rest of my drink out
for my dead homies.
Please help me, I enjoy using Java because I can work with it quickly,
but I feel like screaming sometimes because I can't pass a simple
piece of info to a component. I've learned so much more than I needed
to and wasted so much valuable time trying to do this and I know in my
heart that there is an easy answer that will make me feel
simultaneously stupid and relieved. I need that feeling like you
wouldn't believe, and I'm sure there our other amateur programers out
there who could benefit greatly by understanding why my methods don't
work.
On that note, if you could even explain why solutions like 1) or 4)
don't work, I think a lot of people could benefit from that info.
- 14
- simplifying use of properties"Stefan Schulz" <email***@***.com> wrote in message news:<opsg4x3eg6q1fd9p@localhost>...
> The change you describe is inherently incompatible, though.
Not if you change reflexive field access to match the hardcoded
equivalent.
> In fact, the
> VM you describe is fundamentally different and incompatible to the current
> JVM.
> What you argue for is effectively another language with
> wholely different concepts.
I don't think so.
> I'll not say that these concepts in themselves
> have no merit, but in the Java programming language, they are not
> appropriate, since they run against several other principles of the
> language's
> design.
Like what?
> >> > No merit? Properties are supported in many languages like Python,
> >> > Ruby, C# and (I think) VB.
> >>
> >> So what? They are in java too (see the public modifier for fields) ;)
> > Once you have a public field in Java, you can't later replace it with
> > accessor methods without breaking clients. But in Python, Ruby & C#,
> > you can. That is what I meant by "properties" as opposed to "fields"
> > or "instance variables".
>
> No, you can't. Think about reflexive invocation - Will work with a public
> method, will not work with a inaccessable field, and getter/setter pairs.
That's not a problem; I wasn't proposing changing the semantics of the
invokevirtual instruction for somebody to complain that the parallel
using reflection behaves differently from a hardcoded invocation. What
we do need to change is reflexive field access: it should invoke the
getters & setters when the field isn't found. But that's pretty
logical.
>
> >> It will however make it even more of a living hell to explain tonovices
> >> that a setter/getter pair need not be backed by one andonly one field
> >> of the arguemnt type.
> >
> > Getter/setter pairs that are not backed with fields are used all the
> > time in Java. I'm only proposing an easier syntax for their use.
> > Regarding the novices bit, OO theory says that when you call a method,
> > you should *not* be concerned with how it's implemented. I feel you
> > should not be telling novices that a getter/setter pair always has to
> > be backed with a field.
>
> This is what i said. Most assume it has to be backed by a field, and if
> you use field access syntax, you reinforce that notion.
Maybe, but I still think it's straightforward for novices to
understand that what looks like a field access may be an invocation,
once you explain it to them. There are tougher concepts novices must
understand.
- 15
- What Size Screen Do You Design For?Most of what I've done in Java is for a small business and any GUI had to be
able to be run in a 640x480 screen because some of the software goes on
servers that are hooked up to cheap monitors that aren't used often.
Now I'm writing some simple programs and utilities that I can use and I'm
sure others will like. I'll be releasing them as open source so people can
do what they like. I've realized that I don't have to be bound by the
640x480 screen size anymore, but I don't know what most people tend to have
as a minimum now days.
For just simple stuff that I'd like for most people to be able to use, what
can I count on as the smallest screen size in general use? I was thinking
800x600, but a few friends have told me that most people now can do larger
than that now.
So what do you count on as a screen size your Java GUI programs can expect?
Thanks!
Hal
|
|
|