 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- Java Applet in Mac FireFox sets multiple DIFFERENT cookiesI've been fighting with this one for a couple days. I'm getting two
(different) cookie headers being set.
Quick Background:
- Using a TurboGears web application.
- Embedding an Applet to assist in file uploads (JUpload).
- Applet uploads the files and sends the data to a secure URL.
- A session ID preserves the user's login information so they don't
get a 403 or have to login again.
- Works totally fine in everything EXCEPT FireFox on a Mac (Safari
works fine, as well as FireFox in Windows)
Using Ethereal to look at the HTTP header, there are two "Cookies"
values being set. The one that I set, and some other random one which
I have NO idea where it is coming from. As follows:
POST /import/upload HTTP/1.1
Cookies: tg-visit=2k842fgj237dfkvh232c32hdh3832
Content-length: 123541
<blah blah blah other headers>
Cookies: tg-visit=743jk82hfg94520fng62j8233jfg826
The first tg-visit value (the session id) is correct. The second one
which is the last header being set, is some other id being set. In
Safari the tg-visit value is the same on both lines and it works fine.
Other browsers properly only sets a single line. Firefox on a Mac
gives me two different values, and I have NO idea why.
Code to follow:
<APPLET CODE="foo.bar.myApplet" ARCHIVE="/static/myApplet.jar"
WIDTH="450" HEIGHT="320">');
<PARAM name="type" value="application/x-java-applet;version=1.4" /
>');
<PARAM name="scriptable" value="true" />
<PARAM name="postURL" value="${postUrl}" />
<PARAM name="redirectURL" value="${redirectUrl}" />
<PARAM name="tgVisitValue" value="tg-visit=${tgVisitValue}" />
</APPLET>
I have also tried to use the MAYSCRIPT attribute, but that doesn't
really help.
Using TurboGears which fills in the ${tgVisitValue} properly (which
works fine).
myApplet.java
this.mycookies = this.getParameter("tgVisitValue",
DEFAULT_COOKIE_STRING);
if (this.mycookies == DEFAULT_COOKIE_STRING) {
try
{
JSObject window = JSObject.getWindow(this );
JSObject document =
(JSObject)window.getMember( "document" );
String cookies =
(String)window.eval("self.document.cookie");
if (cookies.equals("undefined")) // we're IE
cookies = (String)document.getMember("cookie");
// NAOMI
// get all the unexpired cookies
// this.mycookies = (String) document.getMember( "cookie" );
}
catch ( Exception e )
{
this.mycookies = "nocookie=0";
}
}
This grabs the cookie value properly, so I don't think there are any
problems there. The code that does all the HTTP magic is here:
try{
String boundary = "-----------------------------" +
getRandomString();
url = new URL(uploadURL);
// Setting up the connection for upload.
urlConn = url.openConnection();
urlConn.setRequestProperty("Cookie", this.mycookies);
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-length", ""+totalFilesLength);
urlConn.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" +
boundary.substring(2,
boundary.length()));
String CRLF = "\r\n";
urlConn.connect();
// Retrieve OutputStream For upload (Post).
dOut = new DataOutputStream(urlConn.getOutputStream());
// Actual Uploading part.
StringBuffer sb;
File f;
uploadedLength = 0;
for(int i=0; i < aTotalFiles.length && !stop; i++){
f = aTotalFiles[i];
sb = new StringBuffer();
// Line 1.
sb.append(boundary);sb.append(CRLF);
// Line 2.
sb.append("Content-Disposition: form-data; name=
\"File");sb.append(i);
sb.append("\"; filename=\"");sb.append(f.toString());
sb.append("\"");sb.append(CRLF);
// Line 3 & Empty Line 4.
sb.append("Content-Type: application/octet-stream");
sb.append("Content-Length: " + f.length());
sb.append(CRLF);sb.append(CRLF);
dOut.writeBytes(sb.toString());
uploadFileStream(f,dOut);
dOut.writeBytes(CRLF);
}
// Telling the Server we have Finished.
dOut.writeBytes(boundary);
dOut.writeBytes("--");
dOut.writeBytes(CRLF);
dOut.flush ();
if(!stop) progress.setString("File(s) uploaded. Wait for server
response!");
bInp = new BufferedReader(new
InputStreamReader(urlConn.getInputStream ()));
Any ideas?
- 1
- Capture keystrokeHi,
I have a command line java program and I am trying to capture a keypress
from the user to say pause or stop the program. The only way I can get
this to work at the moment is to read in a key but the program waits for
the user to press return. I don't want this. I want to read the keypress
asynchronously without the user hitting return.
Anybody give me some pointers to how to do this?
Thanks in advance
Brian
- 1
- Is it possible to design Audio CD player by using Java only?Never tried it myself, but have you looked at java media api. i am thinking
if reading file from the cd in a normal way (binary stream) and then
feeding it to media api can do the job....!!!
Good luck anyways :-)
"MiLF" <email***@***.com> wrote in message
news:bdesn5$rki$email***@***.com...
> I am not expecting how fancy the CD player will be, but basic function is
> enough.
>
>
- 3
- problems with TCPMONHi,
I'm using axis 1.2-RC3 and eclipse 3.01RC. When i run tcpmon from
command line
>java -cp org.apache.axis.utils.tcpmon
i use the panel for setting me as listener on port 8083 while tomcat is
on port 8080.
The problem is that when the client comunicate with server i dont have
2 SOAP messages but the tcpmon loops infinite on an error message.
I cant post you the output because tcpmon goes in infinite loop and its
impossible to copy text.
However i have set the axis path appropriately and i have added it to
classpath and classpath to path so i can call tcpmon with java org.....
I have also the needed jars (expecially) axis.jar included in axis
server (on tomcat) and imported in eclipse project.
Thank you in advance!
- 5
- Seaching word in text file using JAVA.Hello,
I have a problem on seaching word in text file using JAVA.
Below are the sample code i have written for searching word honda,
1990 and imran.I also want to save word honda in static string name
classtring. For first line i use this java code to save word honda in
classtring and its working well. I have a problem to save second line
1990 and imran.
The technique i use is searching until "=" and save word after "=".Can
anyone give the idea and java code.
Thank you...
------------java code ------------------
content = f.readLine();
// find class name
StringTokenizer s = new StringTokenizer (content,"=");
while (s.hasMoreTokens())
{
String string_val = s.nextToken();
if (string_val.trim().equals("classname".trim()))
{
classString=s.nextToken();
}
}
------- data text file -------------
name_car = honda
year = 1990
owner = imran
- 6
- recognizing java processesHow would you recognize a java process (as java process) in runtime
from outside the JVM? (win32)
is there a nicer way than monitorizing DLL loads in order to detect
the jvm.dll/javai.dll load?
- 8
- One class in several filesHello
Is possible make one class in several files ?
I would like do this for organization reason.
Thanks in advice
GG
- 8
- java & CGII am a programming student attempting a quoting system (similar to what
geico does) for my job. I've written a program that is executable from
the command prompt that returns the expected values, but I need it to
work with a webpage.
I want the user to be able to input data, the program process it, and
then display the results. I've found code that uses "POST" to get the
data to a program, but how does the program process it and how do I get
it back into another web page? I've searched the web but I'm having
difficulty finding answers.
Thanks in advance to anyone who can help.
- 9
- J2ME interview questionshey all,
i am wondering if u ca give me j2me interview questions link or u can
advice me regarding that.
Thanks!
- 9
- How to compute a regex match against an object's parameter by name?Consider that you want to do a regex match on the contents of an
attribute of that object. Say, for example, the contents of:
SomeObjectInstance.x
All is well unless you don't know ahead of time that "x" is the
attribute that the user will search against. Suppose that the object
can have any attribute name, and even all those possibilities aren't
known at compile time. The user can/will select this attribute, as well
as the regex pattern.
So the trick is how to apply the match against "x" in this case with
only "x" as a string passed to the method?
// this doesn't work!
public boolean isRegexMatch(String p, String m, SomeObject o, String
attribute){
Pattern pat = Pattern.compile(p);
Matcher mat = pat.matcher(o."attribute"); <--- doesn't work, obviously
return (mat.find());
}
The above would be nice, but as expected-it doesn't work.
So the question is, how to make the method functional without knowing
what it will be passed for "attribute"?
TIA!
BogusException
- 9
- doubtsin javaHelloo
I am a newer one to java. just started to study it. I am getting so
many doubts in the language. I don have any previous knowledge in
progamming.
I would like to know more about JAVA and its applications in the real
world.
Where can I find jobs after studyig it??? From where will I get
practice programs in it???
Thanks in advance
Deepa
- 9
- Reading an array of byte with special delimiter....help me!!Hi guys,
i've developed a java application that has in input a txt file with a
standard format
string string string
string double double
string double double
and stores it into an array of byte with a fixed format,
that is
byte(whitespace)byte(whitespace)byte(;)byte(whitespace)byte(whitespace)byte(;)byte(whitespace)byte(whitespace)byte(;)
that mean introducing byte whitespace value and byte ; value to
separate different columns and different rows.
Now i have to develop inverse routine,that has to read the array of
byte and rebuild its original format.
Can you help me with some idea ord code?
I'm inexepert...please help me with clear suggest...
I post you my routine that converts txt file into an array of byte
P.S.In my txt file number of columns and rows change for each file,what
is standard is a firtst headline that is an array of string and others
row with the same format string array of doubles....
[code]public byte[] getBytes(){
byte middlerow=' ';
byte endrow=';';
Vector temp=new Vector(10000000);
int i=0;
String g=null;
Riga r;
Double val[];
while(i<intest.length){
//copio tutto nell'array di byte
byte []bytes = intest[i].getBytes();
// memorizza in byte un elemento del vettore alla volta
for( Byte aByte : bytes ) {
temp.addElement( aByte );
}
temp.addElement( Byte.valueOf( middlerow ) );
i++;
}
temp.addElement(Byte.valueOf(endrow));
System.out.println("Intestazione convertita in byte");
for(int l=0;l<rows.size()-1;l++){
r=(Riga)rows.get(l);
g=r.getgeneid();
temp.addElement(g.getBytes());
temp.addElement(Byte.valueOf(middlerow));
val=r.getvalues();
for(int e=0;e<=val.length-1;e++){
temp.addElement(Byte.valueOf(val[e].byteValue()));
//val[e].byteValue() fa il casting double in byte
temp.addElement(Byte.valueOf(middlerow));
}
temp.addElement(Byte.valueOf(endrow));
}
byte [] b=new byte[temp.size()];
for (int k=0;i<temp.size();i++){
b[k]=(((Byte)temp.elementAt(k)).byteValue());
}
return b;
}[/code]
Thanks for your help...
- 15
- JBoss 3.2.2 security
Hello,
I'm developing EJB based system on JBoss. The system consists of
two parts: the set of EJB's, mainly Entity Beans which are interfaces
to DB and servlet which is used as user interface. As the interface to
entity beans i'm using statefull session bean. Every call from servlet
have to pass throught it.
To authenticate users I'm using DatabaseServerLoginModule. Users are
able to login, but then they try again to execute eny method from
session bean the server throws exception
Authentication exception, principal=null
What am i doing wrong ?? Should I store the users principal or
it is stored in session context ?
Cheers,
--
Marcin Krasowski mkrasowski (at) zagiel (dot) com (dot) pl
To iterate is human, to recurse divine.
L. Peter Deutsch
- 15
- Non Asian Whore Mature Mummy 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
.
.
.
- 16
- Storing and parsing variable length stringsHi folks...
I have an application which needs to store variable-length strings (up
to 24 characters long) that must then be matched according to prefix.
That is, whenever a prefix is given, the application has to be able to
retrieve all stored strings that start with this prefix. Conversely,
the program has to be able to store strings in such a way, so that
prefix-based retrieving is fast and accurate (i.e., all relative
strings are located and retrieved). Doing this linearly is obviously
slow and inefficient.
So, what is the best way of implementing this functionality in J2SE 1.4
or later? Or, if there is no ready (preprogrammed) way of doing it
properly in the standard distribution, are you aware of any open source
implementation (e.g., tree or something similar)?
Thanks,
Dimitris
|
| Author |
Message |
dar7yl

|
Posted: 2004-8-10 2:24:00 |
Top |
java-programmer, I miss my preprocessor!
There's one thing I really used the C/C++ preprocessor for, and that is
compile-time control of debugging statements.
in it's simplest form:
----------------------------------------------
// comment out this line to disable debugs
#define DEBUG 1
#ifdef DEBUG
# define dbg(msg) printf(msg)
#else
# define dbg(msg)
#endif
void main(int argc, char argv[][])
{
dbg("Some sorta message\n");
}
----------------------------------------------
This system had evolved to a very powerful mechanism for
enabling/disabling/removing debug statements from my code. The beauty of it
is that debugging code can be removed
entirely from released code, without removing from the source. (I like
leaving it in the source because it provides a sort of ancillary
documentation). The only shortcoming was the lack of variable macro
parameters in C/C++.
The nearest I could come up with in java is:
----------------------------------------------
class xxx
{
private static final boolean DEBUG=true; // set to false to turn
off debugging
void dbg(String msg)
{
if (DEBUG) // this gets optimized out
System.out.print(msg);
}
public static void main( String[] args )
{
if (DEBUG) dbg("Some sorta message\n");
}
} // xxx
----------------------------------------------
While this does seem to work, it relies on the compiler to implicitly
optimize the code out. Not that I don't trust the compiler, but how can I
prove it?
From an aesthetic point of view, the "if (DEBUG)" part seems to clutter up
the source.
And it leaves a stub for dbg() in the code.
My point is, what options are available to reproduce the desired mechanism?
(Don't give me anything from java 1.5/5.0; I can't use it till it is
officially released, and the major ide manufactures endorse it).
regards,
Dar7yl (the 7 is silent)
|
| |
|
| |
 |
Artur Biesiadowski

|
Posted: 2004-8-10 3:53:00 |
Top |
java-programmer >> I miss my preprocessor!
dar7yl wrote:
> My point is, what options are available to reproduce the desired mechanism?
Take a look at aspectj. You should be able to turn debug statements to
no-op or redirect it to any logging listener you will like to.
As a side effect, you might be able to remove large number of your debug
statements, as aspectj can generate them for you in some places.
Artur
|
| |
|
| |
 |
Michael N. Christoff

|
Posted: 2004-8-10 4:13:00 |
Top |
java-programmer >> I miss my preprocessor!
"dar7yl" <email***@***.com> wrote in message
news:0jPRc.51443$yT2.44212@clgrps13...
> There's one thing I really used the C/C++ preprocessor for, and that is
> compile-time control of debugging statements.
>
> in it's simplest form:
> ----------------------------------------------
> // comment out this line to disable debugs
> #define DEBUG 1
>
> #ifdef DEBUG
> # define dbg(msg) printf(msg)
> #else
> # define dbg(msg)
> #endif
>
> void main(int argc, char argv[][])
> {
> dbg("Some sorta message\n");
> }
> ----------------------------------------------
>
> This system had evolved to a very powerful mechanism for
> enabling/disabling/removing debug statements from my code. The beauty of
it
> is that debugging code can be removed
> entirely from released code, without removing from the source. (I like
> leaving it in the source because it provides a sort of ancillary
> documentation). The only shortcoming was the lack of variable macro
> parameters in C/C++.
>
> The nearest I could come up with in java is:
> ----------------------------------------------
> class xxx
> {
> private static final boolean DEBUG=true; // set to false to
turn
> off debugging
> void dbg(String msg)
> {
> if (DEBUG) // this gets optimized out
> System.out.print(msg);
> }
>
> public static void main( String[] args )
> {
> if (DEBUG) dbg("Some sorta message\n");
> }
> } // xxx
> ----------------------------------------------
> While this does seem to work, it relies on the compiler to implicitly
> optimize the code out. Not that I don't trust the compiler, but how can I
> prove it?
> From an aesthetic point of view, the "if (DEBUG)" part seems to clutter
up
> the source.
> And it leaves a stub for dbg() in the code.
>
> My point is, what options are available to reproduce the desired
mechanism?
> (Don't give me anything from java 1.5/5.0; I can't use it till it is
> officially released, and the major ide manufactures endorse it).
>
> regards,
> Dar7yl (the 7 is silent)
>
Someone correct me if I'm wrong, but if you do something like this:
public static final boolean DEBUG = true;
...
if(DEBUG) System.out.println("message");
----------
It should do the same thing. To remove the debug code, all you have to do
is change DEBUG to:
public static final boolean DEBUG = false;
---
The Java compiler should remove all debug code in this case, since it can
statically determine at compile time that DEBUG is always false. It is able
to do this because we have declared DEBUG to be 'final'.
l8r, Mike N. Christoff
|
| |
|
| |
 |
dar7yl

|
Posted: 2004-8-10 5:02:00 |
Top |
java-programmer >> I miss my preprocessor!
"Michael N. Christoff" <email***@***.com> wrote in message
news:eVQRc.11067$email***@***.com...
>
> Someone correct me if I'm wrong, but if you do something like this:
>
> public static final boolean DEBUG = true;
> if(DEBUG) System.out.println("message");
>
> It should do the same thing. To remove the debug code, all you have to do
> is change DEBUG to:
>
> public static final boolean DEBUG = false;
>
Didn't I just say that?
>
> The Java compiler should remove all debug code in this case, since it can
> statically determine at compile time that DEBUG is always false. It is
> able
> to do this because we have declared DEBUG to be 'final'.
>
I said that as well, but I also remarked that there is no way to verify that
the compiler will actually do this, now, and in the future. With the C/C++
preprocessor, I am always confident that the code will not be generated.
With java, there is always the possibility that there will still be
reminants in the compiled code.
Btw, is this optimization actually specified in the java standard?
regards,
Dar7yl
|
| |
|
| |
 |
Michael N. Christoff

|
Posted: 2004-8-10 5:33:00 |
Top |
java-programmer >> I miss my preprocessor!
"dar7yl" <email***@***.com> wrote in message
news:FDRRc.51235$hw6.17489@edtnps84...
>
> "Michael N. Christoff" <email***@***.com> wrote in
message
> news:eVQRc.11067$email***@***.com...
> >
> > Someone correct me if I'm wrong, but if you do something like this:
> >
> > public static final boolean DEBUG = true;
> > if(DEBUG) System.out.println("message");
> >
> > It should do the same thing. To remove the debug code, all you have to
do
> > is change DEBUG to:
> >
> > public static final boolean DEBUG = false;
> >
>
> Didn't I just say that?
>
Sorry. I wasn't paying enough attention.
> >
> > The Java compiler should remove all debug code in this case, since it
can
> > statically determine at compile time that DEBUG is always false. It is
> > able
> > to do this because we have declared DEBUG to be 'final'.
> >
>
> I said that as well, but I also remarked that there is no way to verify
that
> the compiler will actually do this, now, and in the future. With the
C/C++
> preprocessor, I am always confident that the code will not be generated.
> With java, there is always the possibility that there will still be
> reminants in the compiled code.
> Btw, is this optimization actually specified in the java standard?
>
I don't think so, but I would be surprised if any modern compiler would not
use such an obvious trick. ie: I'm pretty sure the Java 1.4+ compilers from
BEA, IBM, and Sun do this.
l8r, Mike N. Christoff
|
| |
|
| |
 |
J鰎n W. Janneck

|
Posted: 2004-8-10 5:53:00 |
Top |
java-programmer >> I miss my preprocessor!
dar7yl wrote:
> "Michael N. Christoff" <email***@***.com> wrote in
message
[snip]
>> The Java compiler should remove all debug code in this case, since it can
>> statically determine at compile time that DEBUG is always false. It is
>> able
>> to do this because we have declared DEBUG to be 'final'.
>>
>
> I said that as well, but I also remarked that there is no way to verify
that
> the compiler will actually do this, now, and in the future. With the
C/C++
> preprocessor, I am always confident that the code will not be generated.
> With java, there is always the possibility that there will still be
> reminants in the compiled code.
> Btw, is this optimization actually specified in the java standard?
it's mentioned, but not mandated. i don't know of a compiler that does not
perform it, though---after all it's quite trivial to do.
jls, section 14.20
http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#237366
-- j
|
| |
|
| |
 |
Otis Bricker

|
Posted: 2004-8-10 7:13:00 |
Top |
java-programmer >> I miss my preprocessor!
"dar7yl" <email***@***.com> wrote in
news:0jPRc.51443$yT2.44212@clgrps13:
> There's one thing I really used the C/C++ preprocessor for, and that
> is compile-time control of debugging statements.
>
> in it's simplest form:
> ----------------------------------------------
> // comment out this line to disable debugs
> #define DEBUG 1
>
> #ifdef DEBUG
> # define dbg(msg) printf(msg)
> #else
> # define dbg(msg)
> #endif
>
> void main(int argc, char argv[][])
> {
> dbg("Some sorta message\n");
> }
> ----------------------------------------------
>
> This system had evolved to a very powerful mechanism for
> enabling/disabling/removing debug statements from my code. The beauty
> of it is that debugging code can be removed
> entirely from released code, without removing from the source. (I
> like leaving it in the source because it provides a sort of ancillary
> documentation). The only shortcoming was the lack of variable macro
> parameters in C/C++.
>
> The nearest I could come up with in java is:
> ----------------------------------------------
> class xxx
> {
> private static final boolean DEBUG=true; // set to false to
> turn
> off debugging
> void dbg(String msg)
> {
> if (DEBUG) // this gets optimized out
> System.out.print(msg);
> }
>
> public static void main( String[] args )
> {
> if (DEBUG) dbg("Some sorta message\n");
> }
> } // xxx
> ----------------------------------------------
> While this does seem to work, it relies on the compiler to implicitly
> optimize the code out. Not that I don't trust the compiler, but how
> can I prove it?
> From an aesthetic point of view, the "if (DEBUG)" part seems to
> clutter up the source.
> And it leaves a stub for dbg() in the code.
>
> My point is, what options are available to reproduce the desired
> mechanism? (Don't give me anything from java 1.5/5.0; I can't use it
> till it is officially released, and the major ide manufactures endorse
> it).
>
> regards,
> Dar7yl (the 7 is silent)
>
>
Would it really cost that much to have a class with a static 'Logger'
reference and a static init or method that chooses between a NullLogger and
a DebugLogger. The runtime enviroment should quickly notice that it can
short out the empty implementation. Even if it didn't, what would the cost
be of calling an empty function a couple thousand times? Or using the code
you posted without the local "if(DEBUG)". How much are you really saving by
eliminating the call site? It seems that this is an as yet unjustified
optimization.
A Logging Class would also allow you to turn it on and off with an
eviroment/commandline flag rather than a recompile. For that matter, it
could be toggled inside the program if you wanted to add a way to get to
it.
I've never been fond of the "#ifdef DEBUG #define" trick. It has some uses
but seems too devious. Compile flags changing my code and the execution
path. Now you have to be side effect free. Its not that hard but its
another thing to worry about. And I have caught people messing it up.
Otis
|
| |
|
| |
 |
Artur Biesiadowski

|
Posted: 2004-8-10 14:53:00 |
Top |
java-programmer >> I miss my preprocessor!
Otis Bricker wrote:
> Would it really cost that much to have a class with a static 'Logger'
> reference and a static init or method that chooses between a NullLogger and
> a DebugLogger. The runtime enviroment should quickly notice that it can
> short out the empty implementation. Even if it didn't, what would the cost
> be of calling an empty function a couple thousand times? Or using the code
> you posted without the local "if(DEBUG)". How much are you really saving by
> eliminating the call site? It seems that this is an as yet unjustified
> optimization.
There is a difference in argument handling. Even if implementation is
empty, jvm cannot omit argument creation. So, if you will do
Logger.log("Current value" + compositeObject.toString());
new StringBuffer will be created and compositeObject.toString() method
will be called (which can be possibly quite heavy plus include creation
another StringBuffer/String instance).
On the other hand,
if (DEBUG) Logger.log("Current value" + compositeObject.toString());
will help here - because argument won't be created if DEBUG is false.
But question is how to write it in different way with same
optimalization. My answer is AOP.
Artur
|
| |
|
| |
 |
Tim Tyler

|
Posted: 2004-8-11 0:05:00 |
Top |
java-programmer >> I miss my preprocessor!
dar7yl <email***@***.com> wrote or quoted:
> There's one thing I really used the C/C++ preprocessor for, and that is
> compile-time control of debugging statements.
>
> in it's simplest form:
> ----------------------------------------------
> // comment out this line to disable debugs
> #define DEBUG 1
>
> #ifdef DEBUG
> # define dbg(msg) printf(msg)
> #else
> # define dbg(msg)
> #endif
[...]
> This system had evolved to a very powerful mechanism for
> enabling/disabling/removing debug statements from my code. The beauty of it
> is that debugging code can be removed
> entirely from released code, without removing from the source. [...]
Much the same works in Java.
> The nearest I could come up with in java is:
> ----------------------------------------------
> class xxx
> {
> private static final boolean DEBUG=true; // set to false to turn
> off debugging
> void dbg(String msg)
> {
> if (DEBUG) // this gets optimized out
> System.out.print(msg);
> }
>
> public static void main( String[] args )
> {
> if (DEBUG) dbg("Some sorta message\n");
> }
> } // xxx
> ----------------------------------------------
> While this does seem to work, it relies on the compiler to implicitly
> optimize the code out. Not that I don't trust the compiler, but how can I
> prove it?
Why do you want to prove it. It /does/ normally happen. If you want to
produce brief code you should be using a squeezing tool anyway - and not
relying on the compiler to produce maximally short code.
> From an aesthetic point of view, the "if (DEBUG)" part seems to clutter up
> the source.
Worse than #ifdef DEBUG?
That doesn't just clutter up the source code - it clutters up the whole
language by introducing an unnecessary construct - a second sort of if
statement - making the job of parsers harder.
> And it leaves a stub for dbg() in the code.
So: use a logging class - so your log statement looks like
Log.dbg("msg");
A few extra keystrokes - but a /lot/ neater than putting a dbg(...)
method in every single class.
--
__________
|im |yler http://timtyler.org/ email***@***.com Remove lock to reply.
|
| |
|
| |
 |
dar7yl

|
Posted: 2004-8-11 2:29:00 |
Top |
java-programmer >> I miss my preprocessor!
"Tim Tyler" <email***@***.com> wrote in message news:email***@***.com...
> dar7yl <email***@***.com> wrote or quoted:
>
>> From an aesthetic point of view, the "if (DEBUG)" part seems to clutter
>> up
>> the source.
>
> Worse than #ifdef DEBUG?
>
The "#ifdef DEBUG" is actually not in the source, but is included in the
header, eg:
#include debug.h
(didn't I say that the example I gave was the simplest form? the mechanism
I use is fairly elaborate, with the ability to selectivly turn on/off debugs
by module, level, and other criteria.
The only inclusion within the body of the source (beside the include, and a
few defines to outline the parameters) is the dbg(...) statements. My point
is that the C/C++ preprocessor can control the generation of source with
three letters: 'd' 'b' 'g', while java requires
"if (DEBUG) dbg"... .
>> And it leaves a stub for dbg() in the code.
>
> So: use a logging class - so your log statement looks like
> Log.dbg("msg");
>
> A few extra keystrokes - but a /lot/ neater than putting a dbg(...)
> method in every single class.
didn't I say that the example I gave was the simplest form? I actually have
created a logging class, but I still have the stub:
void dbg( String msg)
{
if (DEBUG)
Logger.dbg(msg);
}
While this does add one level of subroutine call to the debug when it is
enabled, but it avoids a class call when not.
In C/C++, I could have put the stub into a header, and inlined it.
regards,
Dar7yl
|
| |
|
| |
 |
dar7yl

|
Posted: 2004-8-11 2:39:00 |
Top |
java-programmer >> I miss my preprocessor!
Thanks for your reply, Artur. I couldn't have said it better. That's the
whole idea behind the "if (DEBUG)...", to bypass the argument evaluation.
>> My answer is AOP.
Care to elaborate?
regards,
Dar7yl
"Artur Biesiadowski" <email***@***.com> wrote in message
news:email***@***.com...
> Otis Bricker wrote:
>
>> Would it really cost that much to have a class with a static 'Logger'
>> reference and a static init or method that chooses between a NullLogger
>> and a DebugLogger. The runtime enviroment should quickly notice that it
>> can short out the empty implementation. Even if it didn't, what would the
>> cost be of calling an empty function a couple thousand times? Or using
>> the code you posted without the local "if(DEBUG)". How much are you
>> really saving by eliminating the call site? It seems that this is an as
>> yet unjustified optimization.
>
> There is a difference in argument handling. Even if implementation is
> empty, jvm cannot omit argument creation. So, if you will do
>
> Logger.log("Current value" + compositeObject.toString());
>
> new StringBuffer will be created and compositeObject.toString() method
> will be called (which can be possibly quite heavy plus include creation
> another StringBuffer/String instance).
>
> On the other hand,
> if (DEBUG) Logger.log("Current value" + compositeObject.toString());
> will help here - because argument won't be created if DEBUG is false. But
> question is how to write it in different way with same optimalization. My
> answer is AOP.
>
> Artur
|
| |
|
| |
 |
Tim Tyler

|
Posted: 2004-8-11 2:44:00 |
Top |
java-programmer >> I miss my preprocessor!
dar7yl <email***@***.com> wrote or quoted:
> "Tim Tyler" <email***@***.com> wrote in message news:email***@***.com...
> > dar7yl <email***@***.com> wrote or quoted:
> >> From an aesthetic point of view, the "if (DEBUG)" part seems to clutter
> >> up the source.
> >
> > Worse than #ifdef DEBUG?
>
> The "#ifdef DEBUG" is actually not in the source, but is included in the
> header, eg:
> #include debug.h
>
> (didn't I say that the example I gave was the simplest form? the mechanism
> I use is fairly elaborate, with the ability to selectivly turn on/off debugs
> by module, level, and other criteria.
>
> The only inclusion within the body of the source (beside the include, and a
> few defines to outline the parameters) is the dbg(...) statements. My point
> is that the C/C++ preprocessor can control the generation of source with
> three letters: 'd' 'b' 'g', while java requires
> "if (DEBUG) dbg"... .
I think you are saying you'd like a tool that takes
dbg("msg"); calls, and strips them out of the code at
compile time if the method they call does nothing.
I'm not certain if any tools currently do this,
but code squeezers do an /awful/ lot of that sort
of thing to reduce code size - so the chances are
probably pretty good that one of them does.
> I actually have created a logging class, but I still have the stub:
> void dbg( String msg)
> {
> if (DEBUG)
> Logger.dbg(msg);
> }
Again, it's the job of code squeezers to eliminate useless calls to
functions that do nothing.
The compiler's job is normally a bit different from that of a code
squeezer - and it should not attempt to squeeze every last bit
of space out of the compiled code.
> While this does add one level of subroutine call to the debug when it is
> enabled, but it avoids a class call when not.
> In C/C++, I could have put the stub into a header, and inlined it.
Probably not a good idea in Java.
There inlining is done automatically by the runtime - depending on whether
the space/time tradeoff on the client looks favourable or not - and as
I recall, some runtimes actually do experiments in real time to evaluate
whether such inlining is actually helping in practice.
--
__________
|im |yler http://timtyler.org/ email***@***.com Remove lock to reply.
|
| |
|
| |
 |
Artur Biesiadowski

|
Posted: 2004-8-11 4:13:00 |
Top |
java-programmer >> I miss my preprocessor!
dar7yl wrote:
>>>My answer is AOP.
>
>
> Care to elaborate?
Aspect oriented programming.
For more details please look at
eclipse.org/aspectj/
At the moment I'm not able to show you an example which will work
exactly as you want - in fact I'm not sure if it is possible in aspectj
to avoid evaluation of parameters in around() advice (or if there is
some other idiom which can be used here). But I hope it can be managed.
If you will find out exact syntax, please let us know :)
Artur
|
| |
|
| |
 |
Otis Bricker

|
Posted: 2004-8-11 5:59:00 |
Top |
java-programmer >> I miss my preprocessor!
Artur Biesiadowski <email***@***.com> wrote in
news:email***@***.com:
> Otis Bricker wrote:
>
>> Would it really cost that much to have a class with a static 'Logger'
>> reference and a static init or method that chooses between a
>> NullLogger and a DebugLogger. The runtime enviroment should quickly
>> notice that it can short out the empty implementation. Even if it
>> didn't, what would the cost be of calling an empty function a couple
>> thousand times? Or using the code you posted without the local
>> "if(DEBUG)". How much are you really saving by eliminating the call
>> site? It seems that this is an as yet unjustified optimization.
>
> There is a difference in argument handling. Even if implementation is
> empty, jvm cannot omit argument creation. So, if you will do
>
> Logger.log("Current value" + compositeObject.toString());
>
> new StringBuffer will be created and compositeObject.toString() method
> will be called (which can be possibly quite heavy plus include
> creation another StringBuffer/String instance).
>
> On the other hand,
> if (DEBUG) Logger.log("Current value" + compositeObject.toString());
> will help here - because argument won't be created if DEBUG is false.
> But question is how to write it in different way with same
> optimalization. My answer is AOP.
>
> Artur
While it may not be done currently, it seems to me that the VM could
determine that the log call could be inlined as well as the call
toString, then it would notice that the argument is never used and has no
side effects and eliminate it all. HotSpot may not do this yet. But is
there a reason it couldn't?
And I still wonder about the amount of time really spent logging this
stuff. Unless you dump a whole lot of debug info, this really looks like
a fraction of a percent of execution time. I was trying to get across the
idea that this may not be worth worrying about except in some rare cases.
|
| |
|
| |
 |
Artur Biesiadowski

|
Posted: 2004-8-11 6:40:00 |
Top |
java-programmer >> I miss my preprocessor!
Otis Bricker wrote:
> While it may not be done currently, it seems to me that the VM could
> determine that the log call could be inlined as well as the call
> toString, then it would notice that the argument is never used and has no
> side effects and eliminate it all. HotSpot may not do this yet. But is
> there a reason it couldn't?
There is a side effect - creation of String/StringBuffer object at
least. I'm not sure if it is legal for jvm to optimize it away.
public void m() {
Integer i = new Integer(5);
}
Could this be optimized by jvm to no-op ? I'm not sure. Maybe it can
have a hardcoded list of objects which have no side effects when created
- discovering it at runtime is probably too hard.
> And I still wonder about the amount of time really spent logging this
> stuff. Unless you dump a whole lot of debug info, this really looks like
> a fraction of a percent of execution time. I was trying to get across the
> idea that this may not be worth worrying about except in some rare cases.
It really depends on domain and on verbosity of logs. If you are doing
anything game-related for example, even such small costs when added
together can kill performance.
Artur
|
| |
|
| |
 |
Raghar

|
Posted: 2004-8-11 7:50:00 |
Top |
java-programmer >> I miss my preprocessor!
"dar7yl" <email***@***.com> wrote in
news:0jPRc.51443$yT2.44212@clgrps13:
> There's one thing I really used the C/C++ preprocessor for, and that is
> compile-time control of debugging statements.
>
> in it's simplest form:
> ----------------------------------------------
> // comment out this line to disable debugs
> #define DEBUG 1
>
> #ifdef DEBUG
> # define dbg(msg) printf(msg)
> #else
> # define dbg(msg)
> #endif
>
> void main(int argc, char argv[][])
> {
> dbg("Some sorta message\n");
> }
> ----------------------------------------------
>
> This system had evolved to a very powerful mechanism for
> enabling/disabling/removing debug statements from my code. The beauty
> of it is that debugging code can be removed
> entirely from released code, without removing from the source. (I like
> leaving it in the source because it provides a sort of ancillary
> documentation). The only shortcoming was the lack of variable macro
> parameters in C/C++.
>
> The nearest I could come up with in java is:
> ----------------------------------------------
> class xxx
> {
> private static final boolean DEBUG=true; // set to false to
> turn
> off debugging
> void dbg(String msg)
> {
> if (DEBUG) // this gets optimized out
> System.out.print(msg);
> }
>
> public static void main( String[] args )
> {
> if (DEBUG) dbg("Some sorta message\n");
> }
> } // xxx
> ----------------------------------------------
> While this does seem to work, it relies on the compiler to implicitly
> optimize the code out. Not that I don't trust the compiler, but how can
> I prove it?
> From an aesthetic point of view, the "if (DEBUG)" part seems to clutter
> up the source.
> And it leaves a stub for dbg() in the code.
>
> My point is, what options are available to reproduce the desired
> mechanism? (Don't give me anything from java 1.5/5.0; I can't use it
> till it is officially released, and the major ide manufactures endorse
> it).
>
Tie him up, remove his upper clothes. Tie him to the pole with his hands
safely tied behind his back properly cinched. Then blindfold him. Take ruber
hose. Open water valve and stream that cold water on him. If he wont come to
senses cuff him and leave him here until morning.
Then again, better would be to strip him and balltie him. Leave him in dark
room for quarter of hour. Then ask him if he came to his senses.
Debug messages cluttering source code. Ouch. And preprocessor syntax
cluttering source code on the top. Crawl 3.3, or so, provided enough warnings
against such behaviour.
Here is some code:
public final boolean shit = false;
public void ug(){
if(shit){System.out.print("shit");}
}
And here is some dissasembly:
public final boolean shit = false;
public void ug() {
}
--
Kizutsuite 'ta ano hi kara
|
| |
|
| |
 |
dar7yl

|
Posted: 2004-8-11 8:12:00 |
Top |
java-programmer >> I miss my preprocessor!
"Artur Biesiadowski" <email***@***.com> wrote in message
news:email***@***.com...
>>>>My answer is AOP.
>> Care to elaborate?
>
> Aspect oriented programming.
> For more details please look at
> eclipse.org/aspectj/
>
I've seen aspectj, and it looks nice from a gee-whiz 2nd year computer
science course point of view. Instead of simplifying things, it seems to
complicate matters.
IMHO, it does not add enough to overcome the steep learning-curve it forces
my poor human-sized brain into.
regards,
Dar7yl
|
| |
|
| |
 |
dar7yl

|
Posted: 2004-8-11 8:23:00 |
Top |
java-programmer >> I miss my preprocessor!
"Raghar" <email***@***.com> wrote in message
news:email***@***.com...
>> ...insults and profanity deleted...
please refrain from exposing your immaturity. If you have a point, state
it.
regards,
Dar7yl.
|
| |
|
| |
 |
The Ghost In The Machine

|
Posted: 2004-8-12 0:01:00 |
Top |
java-programmer >> I miss my preprocessor!
In comp.lang.java.advocacy, dar7yl
<email***@***.com>
wrote
on Wed, 11 Aug 2004 00:22:57 GMT
<BFdSc.995$X12.901@edtnps84>:
>
> "Raghar" <email***@***.com> wrote in message
> news:email***@***.com...
>
>>> ...insults and profanity deleted...
>
> please refrain from exposing your immaturity. If you have a point, state
> it.
> regards,
> Dar7yl.
>
Indeed.
I'd think, though, that explicitly typing in those statements is a PITA. :-)
--
#191, email***@***.com
It's still legal to go .sigless.
|
| |
|
| |
 |
Raghar

|
Posted: 2004-8-12 5:52:00 |
Top |
java-programmer >> I miss my preprocessor!
"dar7yl" <email***@***.com> wrote in news:BFdSc.995$X12.901@edtnps84:
>
> "Raghar" <email***@***.com> wrote in message
> news:email***@***.com...
>
>>> ...insults and profanity deleted...
>
> please refrain from exposing your immaturity. If you have a point, state
> it.
I'm sorry if you are taking it as a insults and profanity. I thought I'm
pretty clear. I consider debug messages cluttering source code in C++ way as
a worse alternative to the above statements.
(Yes I consider a preprocessor a slightly better alternative to the Bush
reelection... doomed or very doomed what's better?)
"> While this does seem to work, it relies on the compiler to implicitly
> optimize the code out. Not that I don't trust the compiler, but how can
> I prove it?"
I proved it in my post.
Alas I didn't find that really ugly part of crawl source code, nor I found a
really effective example of define, undefine, ifdef, ifndef, and so on.
However I found a really nice source codes without defines that were nicely
commented. It's a part of the Java standard library source code, and the Kent
Paul Dolan's Traveller source code. You could easily find answers on your
questions in the former, and you could easily continue with development of
the later.
About what we talked about? Defines and source code?
">Btw, is this optimization actually specified in the java standard?"
Not, and it shouldn't be. Any compiler is able to remove "branch" statement
from the code with exception of experimental and beta versions of compiler.
">My point is, what options are available to reproduce the desired mechanism?
>(Don't give me anything from java 1.5/5.0; I can't use it till it is
>officially released, and the major ide manufactures endorse it)."
IDE manufacturers? O_O
--
Kizutsuite 'ta ano hi kara
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- java.net SocketPermissionHi,
I am getting the SocketPermission deny error when I trying to run my
applet on the net. When I was running stand along, embed in the frame,
on my local PC, it was no problem. Help!!!
eric
- 2
- Problem with table nameHi!
I have a problem to access tables in an Informix Database. Table names
are something like that :
informix.pv_tvvte
When I try a "SELECT informix.pv_tvvte.numero_vente FROM
informix.pv_tvvte WHERE informix.pv_tvvte.numero_vente=#value#", (I use
ibatis and spring) I get a syntax error exception (SQLException "Bad SQL
Grammar").
If I replace dot with "_" in the name, I get a "Table Not Found" Exception.
How could I escape the dot in the tables names ?
TIA
Arnaud
- 3
- Progress bar in JDialogHi all,
I am a new beginner to Java Programming. In my application I am loading
an xml doc in JFrame, while doc is loading I would like to see a
progress bar above the J frame.
This is what I did:
I created a modal JDialog with a progress bar, to be able to show the
dialog above the frame. But if I do that then it freezes the loading of
the xml doc in my Jframe. In other words, only after I close the
JDialog I am able to load the document in my JFrame. Hence, the whole
point of showing a progress bar while loading the document is missed.
How to get over this problem. Can anyone please help.
Any input is greatly appreciated.
Thanks
Nathan
- 4
- but *very* apropos] Future reuse of codeLOL!
I enjoyed reading that...
I think "Nihil Software" was a bit of a giveaway... Maybe some of my posts
in the 90s inspired the author <G>.
I hasten to add that this is NOT what we were intending to do with Dulcinea.
Natural language interfaces are not SO hard to write (I wrote one for MS-DOS
that allowed people who didn't like the command line to communicate in
English.) It was distributed by a computer vendor in North Sydney as an
incentive to buy machines from him. He paid me $10 for every machine he sold
with it on...(It was called "IGOR" - Interactive Guide to On-line Running
<G>.) I did it because someone said it couldn't be done, and wasn't really
interested in it as a money maker.
He sold several hundred machines with it on, before Windows 3.1 came out and
blew it all away.... I received mail from people up to 2 years afterwards
saying how much they liked it. (If they asked IGOR about his life he would
give them my e-mail address, as well as an amusing tale of how he escaped
from Frankenstein's lab <G>)
The concept engine would have used a similar Natural Language simulation for
interaction with the User, but it would have no UNDERSTANDING of what the
language meant (apart from keywords which it would act upon).
Nowadays of course, there are some very good Natural Language interfaces and
they are quantum leaps beyond IGOR.
Don't let the fact that a magazine caught you with a hoax, persuade you that
such software will never be developed.
Thanks for posting it, John.
Pete.
"jce" <email***@***.com> wrote in message
news:XOkYa.17847$email***@***.com...
> Here is a classic gotcha from Software Development magazine that I
consider
> appropriate enough to consider sharing.. you are fortunate enough to have
a
> disclaimer on the online version...those of us who read this back then
(and
> are gullible) actually believed it for a moment :-)
>
> http://www.sdmagazine.com/documents/s=819/sdm0204f/
>
> You may have to register but you can make up a name...you could sign up
for
> the free magazine (maybe not in nz) but it's a pretty interesting magazine
> that doesn't take long to flip through.
>
> Here's the intro:
> Once every decade or so, a technology comes along that changes the
software
> landscape, becoming an indispensable part of the developer's life.
Although
> just about every new software concept touts itself as something that will
> "change the way we work," only a handful truly possess such far-reaching
> consequences. One key advance in our field was object-oriented
programming.
> Another is the increasing level of abstraction in the tools that
developers
> use. What shape might the next advance take?
>
> The R&D folks at Nihil Software believe they have the answer. Their
> innovation is called Natural Language Design (NLD), an approach that
enables
> rapid construction of complex software systems using natural (spoken or
> written) language to specify the program. Using this approach, and the
> accompanying tools that Nihil has provided as reference implementations,
you
> can verbally describe the system you want to build and literally see it
> constructed as you speak. That's right, you heard me, no programming.
> Skeptical? Read on.
>
> John (jce)
>
> "Peter E.C. Dashwood" <email***@***.com> wrote in message
> news:email***@***.com...
> > TOP Post only.
> >
> > Dennis,
> >
> > I have believed for some years now that the lack of ARTIFICIAL
> intelligence
> > to generate systems can be compensated for (until it actually arrives
> around
> > 2020...<G>) by putting a Human (or Humans) in the loop.
> >
> > This was revealed to me in a blinding flash of insight (kind of like
Saul
> > on the road to Damascus <G>) when I was trying some new approaches to
> > Project Management and instigated some RAD type workshops. The keys are
> > INTERACTION and ITERATION. Do something, look at it, discuss it,
evaluate
> > it, change it, look at it again and repeat this process for a finite
> period
> > of time or until the desired goal is attained.
>
>
- 5
- Reverse order using Struts iterate tag"Bob" <email***@***.com> wrote
> I am fairly new to struts. Is it possible to iterate backward through
> a collection when using the struts iterate tag? We would like to list
> the values in reverse order on the page.
Yes, I've got things listing in reverse date order in my own Struts webapp.
However, I don't think this has anything to do with Struts. <logic:iterate>
and <c:forEach> are going to return the items in whatever order they come
out of the Iterator returned by the Collection's iterator() method.
To make things sort "backwards", you can override the 'compareTo' method
(and probably equals and hashCode, to be completely correct) on the class of
the objects in your collection. Then call Collections.sort with your
Collection. (I think you can also use a Comparator instead of overriding
compareTo, but that's not how I did it. Actually, looking through my code I
think I may have sorted these on the database side before returning the data
to the DAO! But it's still possible.)
Then when you get to the JSP the logic:iterate tag should display things in
reverse order.
Can you post the JSP and let us know what type of objects you have in your
Collection?
--
Wendy in Chandler, AZ
- 6
- The solutions are very OS specific.Hi Mark Thornton,
You wrote,
" The rough equivalent to an HDC is
a java.awt.Graphics object,
extended ( since Java 1.2 ) to java.awt.Graphics2D.
These are used for drawing to screens, printers
or into a BufferedImage. "
That's quit impressive,
But my bank simulation currently requires Excel,
which precludes Linux.
Also, if I ever moved my simulations to Direct Draw 7,
or even Direct 3D 9 ( instead of the GDI )
once again I'd be forced to use C++,
as DD7's interaction with MS windows is very tricky
and very OS specific.
For example,
Windows' taskbar hoards it's mouse messages.
The taskbar also turns on the system cursor,
which blocks VRAM-to-VRAM blts.
The solutions are very OS specific.
Would the bankers pay for that ? I doubt it.
- 7
- to whom it may concern
"pcbutts1" <email***@***.com> wrote in message
news:4e23e9d12ed44ede9a25a80dde27d810@erollscom...
>
> You don't, by any chance, have a tape recorder?
>
No. But I do own a shovel. I also own several high powered rifles and I'm
very proficient in using them. Capisce?
- 8
- compression API available in Java & C++?Apologies if this is slightly off-topic ...
I'm looking for a compression algorithm that works better than gzip
for small (12 bytes or so) chunks of data. Ideally there would be a
free implementation for Java and C++ that we could use for commercial
purposes.
Specifically, we are streaming data from a C++ server to a Java applet
and would love to use as little bandwidth as possible.
We're not using any form of compression right now, but the belief is
that gzip works in blocks, so small chunks of data don't get much
benefit. (Anyone disagree?)
--
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
- 9
- Eclipse : JCE problemHi,
I have this exception when I launched an application from Eclipse 2.1.
java.security.NoSuchProviderException: JCE cannot authenticate the provider
SunJCE java.lang.NullPointerException
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.SecretKeyFactory.getInstance(DashoA6275)
at
cms.security.SecurityConfiguration.getSecretKeyFactory(SecurityConfiguration
.java:196)
at
cms.kms.PBEKeyHandlingService.loadValuesFromSecurityConfig(PBEKeyHandlingSer
vice.java:276)
at
cms.kms.PBEKeyHandlingService.<init>(PBEKeyHandlingService.java:114)
at cms.backend.JCECryptoService.<init>(JCECryptoService.java:129)
at services.CryptoService.<init>(CryptoService.java:68)
...
I'm using JDK ver. 1.4.0. I'm have replaced local_policy.jar and
US_export_policy.jar with an unlimited strength version.
However, this exeception is NOT thrown when I launched the same application from
command line. It only happen when I executed it inside Eclipse environment.
Any advice?
TQ
/lim/
- 10
- Basic FreeBSD Java/Tomcat questionsHello, all=2E I'm an old hand with Java but relatively inexperienced with=
FreeBSD, and I've never run Java there until the last few days=2E I had a=
few things I was wondering about=2E I can't find these things in the
archives, and don't know where else to look=2E Some of my questions might=
betray my lack of FreeBSD knowledge =2E=2E=2E
My preferences:
1=2E Avoid customization to the extent possible -- I don't really want to=
spend much energy being an admin -- even if my configuration is not
optimally flexible, or whatever=2E This means I'd prefer to use packages
from 5=2E4-RELEASE as opposed to ports, etc=2E
2=2E Not to have to build full JDK (with web start, plugins, etc=2E) --
building minimal took days as it was=2E
3=2E Simplest system possible, fewest installs possible, ease of
administration/use=2E
Here's what I've done so far:
1=2E Installed FreeBSD 5=2E4-RELEASE (minimal distribution set only)
2=2E Built jdk-minimal-1=2E4=2E2p7 from source on test machine=2E Seemed=
to go
fine=2E Created package using pkg=5Fcreate -b =2E=2E=2E
3=2E Installed jdk-minimal-1=2E4=2E2p7 as package=2E java -version works=
; haven't
tried much else, except =2E=2E=2E
4=2E jakarta-tomcat-5=2E0=2E30 as package WITHOUT its dependencies (i=2Ee=
=2E,
pkg=5Fadd -r from my own server, which does not have the fonts stuff on it=
)=2E=20
Besides emitting the predicatable complaints about missing dependencies,
the pkg=5Fadd command emits a warning saying the jdk package is required a=
nd
I have jdk-minimal=2E
5=2E Tomcat post-install
cp conf/server-minimal=2Exml=2Esample to conf/server=2Exml
cp conf/web=2Exml=2Esample to conf/web=2Exml
chown www conf/*=2Exml
/usr/local/etc/rc=2Ed/020* start
What happens:
It works, so far as I can tell=2E This means that I've gone to the home
page, not tested extensively=2E The 'balancer' webapp doesn't initialize
correctly (fails with NoClassDefFoundError on
org=2Eapache=2Ecommons=2Edigester=2EDigester) but I'm not too worried abou=
t that
since I don't know exactly what it's for and I haven't read any docs yet=2E=
Questions:
1=2E Why does Tomcat depend on all the font stuff=3F Can I safely run wi=
thout
it=3F
2=2E Same question with the jdk vs=2E jdk-minimal issue=2E
3=2E What are the limitations of tomcat50ctl=3F I've seen some messages =
in
the archives saying I'll need to change my /usr/local/etc/rc=2Ed script if=
I
want to do things like command-line arguments to Tomcat, etc=2E
Comments:
I'm really pleased (as I've worked through these issues) about how smart=20=
the packaging system is (e=2Eg=2E, not deleting files if they've been chan=
ged)=2E
Not sure to what extent credit is due FreeBSD developers and to what exten=
t
credit is due to people on this list, but take whatever you're entitled to=
=2E
:)
Special praise for the jdk14 port -- for such a complex build, I'm shocked=
how well it worked for me, particularly since I know very little about mak=
e=2E
Cheers,
-- David=2E
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web=2Ecom/ =2E
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 11
- java.util.regex - combining paragraphs separated by blank lineI need to write a regular expression to group lines of text separated
by a blank line.
Ex.
Input:
line1
line2
line3
line 4
line 5
line 6
I tried turning on the MULTILINE and DOTALL flags and used the
following pattern:
(.+?)^$
which is close but prepends a newline to the 2nd and subsequent calls
to Matcher.find().
The first line of every paragraph is the same, if that helps.
Regex's are cool, but frustrating....
- 12
- HTML Parser Help PleaseHi
I am using HTMLEditorKit.Parser class to parse a HTML file. However, I have
found this Swing HTML parser extremely difficult to use.
I am trying to parse a HTML file and extracting specific information from it
into a table. Consider the snippet of my HTML and the table I like it to
generate:
HTML source:
<HTML>
<TITLE></TITLE>
<BODY>
<PRE>
Identifer: ABCDEFG
</PRE>
data: 123456
<PRE>
</PRE>
</BODY>
</HTML>
TABLE:
ABCDEFG 123456
Here is the code I have so far:
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.io.*;
public class HTMLParser extends HTMLEditorKit
{
public HTMLEditorKit.Parser getParser()
{
return super.getParser();
}
public static void main (String[] args)
{
try
{
Reader r = new FileReader("html_file.html");
HTMLEditor.Parser parse = new HTMLParser.getParser()
HTMLEditorKit.ParserCallback cb =
{
public void handleStartTag(HTML.Tag t, MutableAttributeSet
a, int a)
{
if (t==HTML.Tag.PRE)
{
//print whats between the pre tag
}
}
public void handleText(char[] data, int pos)
{
//print whats between the pre tags
}
};
parse.parse(r, cb, true);
}
catch (IOException e)
{
System.out.println(e);
}
}
}
I would appreciate it very much if someone could solve this problem for me.
I tried the sun tutortial, but the examples aren't that clear enough for me.
Thanks
ZOCOR
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.760 / Virus Database: 509 - Release Date: 10/09/2004
- 13
- lose request focushello
I have some buttons on my UI and a textfield.
when the user dont click one of my buttons the focus from the textfiled
is lost
how solve this?
in onEvent(Event event)
{
if(event.target==button1)
do something
else if(event.target==button)
..........
like this is going......
what should I add to the method to catch the event(click somewhere in
UI,but not in my object(buttons......)) properly?
- 14
- queue management with "application failure management"hi,
I am looking for something which looks like the message queue of the IPC
systemV with java.
my requirements are:
-management of a queue. one application adds data in this queue and
another gets data from this queue.
-simple : no server like JMS. (btw if you know some JMS implementation
without a server it could be what I want). could be in a file.
-no data lost if one application crashes. ie if the application which
gets data from the queue crashes, the other can continue to add data to
this queue and the processing will continue without losing data once the
crashed application is restarted.
do somebody know some libs which implements this?
thanks.
- 15
- Watch NFL Games OnlineWatch NFL Games Online!
For every one who wants to watch the games online because they dont live in the teams town or are at work i found a site that has basically every game covered. Its perfect if you have afford a monthly $70 direct tv nfl access subscription. they got a bunch of channels
The sites http://nflonline.wizhoo.com
|
|
|