| Best tool/methodology/practise for Java code protection ? |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- A sentence out of my anticipation!Hello Everybody:
Here is a demo to test java's multithread:
class MyThread extends Thread{
public void run(){
while(true){
System.out.println(getName() + " is running!");
try{
sleep(1000);
}catch(InterruptedException e){
System.out.println(e.getMessage());
}
}
}
}
class InterruptThreadDemo{
public static void main(String[] args) throws InterruptedException{
MyThread m = new MyThread();
System.out.println("Starting thread...");
m.start();
Thread.sleep(2000);
System.out.println("Interrupt thread...");
m.interrupt();
Thread.sleep(2000);
System.out.println("Stopping application...");
}
}
The result is:
Starting thread...
Thread-0 is running!
Thread-0 is running!
Interrupt thread...
Thread-0 is running!
sleep interrupted
Thread-0 is running!
Thread-0 is running!
Stopping application...
Thread-0 is running!
Thread-0 is running!
Thread-0 is running!
Thread-0 is running!
Thread-0 is running!
......
The outcome is bit out of my anticipation:
What happened to create the sentence "sleep interrupted!"
Any help will be greatly appreciated!
- 1
- Failed to create Java Project...I have an existing Java project with an ant build scrip, build.xml. I
tried to create an Eclipse project by using the "Java Project from
Existing Ant Buildfile" wizard. However, every time I select the
build.xml file in the "Ant Buildfile" field, there is an error
The file selected is not a valid Ant buildfile
However, I can use ant to build using the same build.xml file. My
questions:
1. Is there a more detailed error message from Eclipse about what's
wrong with the "build.xml" ant file I specified in the New
project wizard?
2. How is the Ant/Eclipse integration happen? Which ant executable
does Eclipse use? Could it be that my problem is actually a
configuration problem?
Here are my environments.
OS: Linux river 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008
i686 GNU/Linux
Eclipse: Version: 3.2.2
Build id: M20070212-1330 ('Ubuntu' version: 3.2.2-3ubuntu3)
Java: Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode,
sharing)
Ant: Apache Ant version 1.7.0 compiled on August 29 2007
Thanks in advance,
Estro
- 2
- A free tool like ErwinHello.
I am looking for a free tool like Erwin
(Erwin is a tool that show the whole schema database or part of it as an ERD
diagram.
It has algorithms to show the ERD in minimal place, with minimal crosses
between lines).
Thanks :)
- 2
- Wasp server - SOAP - Circular referencesHi there,
I'm using Systinet WASP Server for Java and I'm having troubles with a
web service of mine which methods return custom objects with circular
references. At the moment, return values serialization causes infinite
loops and I can't figure out how to get WASP to serialize those object
using multiref.
This is so bloody frustrating, please help me.
Thanks a lot in advance.
Kind regards
Adrien
- 4
- How to find a whether a method is used by particular thread or not?Hi,
I am not familiar with Thread in java.I have one scenario.Let
me explain conceptually.
suppose i have one method
public synchronised void m1()
{
....
}
and another
public synchronised void m2()
{
......
}
Suppose i have two threads T1,T2.
Now what i want is , if T1 is accessing m1() i don't want T2 to access
m2().Please give me some idea how to do this.Which methods i can use
to identify this?
I will be very thanlful ,if somebody can exaplain me this with an
example programmatically.
Regards,
Siva
- 6
- Q: How to organize unit testingIf I have a custom library formed by a package hiarachy build over the
years, what is the usual way of organizing JUnit testing?
Placing a suite in every package which wraps test case classes is messy
and pollutes the library when deployed as a jar.
I see two possebilites, either separate the tests by the use of
preprocessor build directives (but Java has none right?) or create a
mirror of the library package structure where only the tests live. Which
is the common practice and what problems should I look out for?
Thanks in advance,
Casper
- 8
- Can't detect initial thread stack location - ??Running Java on a Linux system (Red Hat 9), I get this error:
Java HotSpot(TM) Client VM warning: Can't detect initial thread stack
location - find_vma failed
I suspect a library file is missing or incorrect, but I can't figure
out what...
Anyone got any ideas about this?
This is my version info:
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
-----------------------------------------------------------------
John English | mailto:email***@***.com
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
School of Computing & MIS | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
- 8
- java/61407: jdk14 port aborts making html32dtd
>Number: 61407
>Category: java
>Synopsis: jdk14 port aborts making html32dtd
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: freebsd-java
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Jan 15 21:20:03 PST 2004
>Closed-Date:
>Last-Modified:
>Originator: Alan Batie
>Release: FreeBSD 4.8-STABLE i386
>Organization:
RainDrop Laboratories
>Environment:
System: FreeBSD pyrex.batie.org 4.8-STABLE FreeBSD 4.8-STABLE #1: Sun Nov 9 03:18:36 PST 2003 email***@***.com:/usr/src/freebsd/src/sys/compile/PYREX i386
Latest jdk14 port using patchset 6:
# $FreeBSD: ports/java/jdk14/Makefile,v 1.71 2004/01/14 21:21:52 glewis Exp $
>Description:
>How-To-Repeat:
cvsup (this morning about 5:30 or so PST)
cvs update ports
cd ports/java/jdk14
make
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
>>>Recursively making html32dtd html32dtd @ Thu Jan 15 20:56:04 PST 2004 ...
gmake[4]: Entering directory `/usr/src/ports/java/jdk14/work/j2se/make/javax/swing/html32dtd'
gmake make-html32dtd
gmake[5]: Entering directory `/usr/src/ports/java/jdk14/work/j2se/make/javax/swing/html32dtd'
/bin/mkdir -p /usr/src/ports/java/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/obj
/bin/mkdir -p /usr/src/ports/java/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/dtdgenclasses
rm -f /usr/src/ports/java/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/.classes.list
if [ -s /usr/src/ports/java/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/.classes.list ] ; \
then /usr/src/ports/java/jdk14/work/control/build/bsd-i586/bin/javac -J-XX:ThreadStackSize=768 -J-Xms64m -J-Xmx256m -J-Xmaxf1 -classpath /usr/src/ports/java/jdk14/work/control/build/bsd-i586/classes -bootclasspath "/usr/src/ports/java/jdk14/work/control /build/bsd-i586/lib/jce.jar:/usr/src/ports/java/jdk14/work/control/build/bsd-i586/lib/jsse.jar" -sourcepath "/usr/src/ports/java/jdk14/work/control/build/bsd-i586/gensrc:../../../../src/solaris/classes:../../../../src/share/classes" -d /usr/src/ports/jav a/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/dtdgenclasses -source 1.4 \
../../../tools/dtdbuilder/PublicMapping.java ../../../tools/dtdbuilder/DTDParser.java ../../../tools/dtdbuilder/DTDInputStream.java ../../../tools/dtdbuilder/DTDBuilder.java ; \
fi
rm -f /usr/src/ports/java/jdk14/work/control/build/bsd-i586/classes/javax/swing/text/html/parser/html32.bdtd
(/usr/src/ports/java/jdk14/work/control/build/bsd-i586/bin/java -ms16m -mx64m \
-classpath "/usr/src/ports/java/jdk14/work/control/build/bsd-i586/tmp/javax/swing/html/dtbuilder/dtdgenclasses:" \
-Ddtd_home=../../../tools/dtdbuilder/dtds \
dtdbuilder.DTDBuilder html32 > /usr/src/ports/java/jdk14/work/control/build/bsd-i586/classes/javax/swing/text/html/parser/html32.bdtd) || exit 1
[Parsed DTD html32 in 197ms]
Abort trap (core dumped)
gmake[5]: *** [/usr/src/ports/java/jdk14/work/control/build/bsd-i586/classes/javax/swing/text/html/parser/html32.bdtd] Error 1
gmake[5]: Leaving directory `/usr/src/ports/java/jdk14/work/j2se/make/javax/swing/html32dtd'
gmake[4]: *** [swing-html32dtd] Error 2
gmake[4]: Leaving directory `/usr/src/ports/java/jdk14/work/j2se/make/javax/swing/html32dtd'
gmake[3]: *** [html32dtd] Error 1
gmake[3]: Leaving directory `/usr/src/ports/java/jdk14/work/j2se/make/javax/swing'
gmake[2]: *** [all] Error 1
gmake[2]: Leaving directory `/usr/src/ports/java/jdk14/work/j2se/make/javax'
gmake[1]: *** [all] Error 1
gmake[1]: Leaving directory `/usr/src/ports/java/jdk14/work/j2se/make'
gmake: *** [j2se-build] Error 2
*** Error code 2
Stop in /usr/src/ports/java/jdk14.
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 8
- Packaging Maven 2 - shipping binaries for bootstrapping.-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi debian java folks, hi mentors,
I'm posting this to mentors, too, because the problem described below is
not only about maven2 but about a general problem with bootstrapping
circularely depending packages.
More news on packaging maven2. I was able to built some more
dependencies of maven2 as debian packages. Now, I reached a point where
I need a hint:
Maven-components is built with a custom bootstrapping shellscript which
builds some core components of maven2 and then builds maven2 with the
help of the bootstrapped libraries. Maven-repository-metadata built
during the bootstrapping depends on a modello-test. modello-test itself
depends on maven-artifact. Modello test is a seperate package which
shall be built seperately from maven2. Because maven-repository-metadata
and maven-artifact are built using the bootstrapping script in one build
run there is a circular dependency. Think A -> C, C -> B where A and B
are in the same source package, C is in another.
I see two ways of breaking this:
First, ship modello as binary jar file with the first source tarball of
maven2 until maven2 is in the archives and can build modello. The
license of modello allows the binary contribution. The later versions
can be built with the packages from the archives then.
Second option: Split maven-components into several packages. This will
be not very easy because of the sophisticated bootstrapping of maven2.
The process buils some bootstrapping code using a shellscript which
build a level 2 bootstrapper which builds the maven core which builds the
maven plugins. Event then, marven-artifact must be shipped as a separate
source package because of the dependencies described above.
Any objections against using the first method to get an initial version
of maven2 into the archives?
- -billy.
- --
Philipp Meier - email***@***.com
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEBsFcZo1qZ89k76URAmr1AJ40B4RYzOuAqABmpLIO06i3eNDlEgCeKGHb
PY1IMs2WCmxCclyrxJUIbRQ=
=iZFw
-----END PGP SIGNATURE-----
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 10
- 11
- HTML 4 JeditorPane - is that possible?Does anyone know of some classes that can act as an HtmlEditorKit
replacement which supports html 4.
I would like to have some documents to be printed or either saved in html
format.
I managed to do that but table border are not printed out, and I have not
find a way to incorporate JPEG pictures in such printouts, since files
should be packaged in jars...
Any ideas?
- 12
- How Do I Get My Open Source Software Online?Good day all,
I have recently spent almost 8 months continuously developing a bulletin
board system in J2EE. I want to get my software online and I've decided to
make it open source, but have a few questions in regards to that:
1. What would be a good place to put it online?
2. Are there any free servers out there where I could put a fully
functioning version up? This would be were people could ask me questions
about the program, share info with each other, etc...
3. Lastly, I still want to retain copyright of my code, but at the same time
permit people to modify it. So would the GNU PL be good for this, or should
I create my own?
Thank you very much for any suggestions and help.
Emery.
/\^/\^/\
Take a Peek Behind My Lens
http://members.shaw.ca/emerysphotography/
- 12
- platform default charsetHello,
How can I change the platform's default charset used by a VM ?
I am talking about the charset used by String methods such
byte[] getBytes()
Encodes this String into a sequence of bytes using the
platform's default charset, storing the result into a new byte array.
Thank you,
Christophe
- 13
- session data on hard diskHello.
I am trying to find the place on the hard disk where the browser writes
out the session information used by my app, the place where the objects
and their values are stored. Is it in the Temp Internet Files or the
Cookie folder? I am running win2k as my testing environment.
Thanks,
Eugene.
- 13
- Ease of Development in Enterprise JavaBeans TechnologyEnterprise JavaBeans (EJB) technology is a J2EE technology for developing
business components in a component-based, enterprise Java application. There's
a new article available that addresses an overview of EJB technology
and information on developing an Enterprise Bean with EJB.
Read about it here:
http://java.sun.com/developer/technicalArticles/ebeans/ejbease/index.html?ssobm=ng
|
| Author |
Message |
exquisitus

|
Posted: 2005-2-21 2:08:00 |
Top |
java-programmer, Best tool/methodology/practise for Java code protection ?
I'm writing a commercial engineering library and I am very uneasy about
the apparent ease with which Java binaries are reverse engineered.
I would like to hear from anyone who uses a tool (commercial or
otherwise) for protecting their IP (in the form of source code) when
they distribute their binaries. For obvious reasons, I am not interested
in hearing from any vendor (or employee thereof) who will naturally be
biased in favour of their offering. I will be most interested in hearing
from people who have actually deployed binaries out there in the field,
and are happy with their obfusucation/encryption tool, methodology or
policies etc.
MTIA
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- A grammar lesson for EdEd wrote:
> Yes, I do! The fact that I got the 5-start ratings on my postings
> explaining how you was rude to me, makes me to kind of trust the
> google ratings!
(To readers of m.e.l.e: this is a perfect example of how NOT to write
English.)
(P.S. I know I shouldn't do this, but it is just too fun to pass up ;-))
Several comments to explain about why this is not proper grammar:
In English, the word `was' indicates the past participle of `to be' in
the third person singular form /only/. The relevant past participle
(here, we need to be in second person, which corresponds as well to all
plural forms) that you are looking for is `were'.
The construction `to make one' is not followed by the word `to'; what
you need to do is drop that word from the following infinitive.
There is no word called `google' (there is a `googol', as in 10^100). If
you are referring to the company with that name, then your
capitalization should reflect that, as a proper noun [*]: `Google'.
Semantically, that classifies all of your sins; however, your choice of
words is not the most appealing in the world.
`To get' is very slangy, and, seeing as Usenet expects a certain level,
of professionalism, the better verb is `to receive'.
I know of no rating that uses `starts'; are you looking for `star'?
`5' should not be written as a digit (as well as other numbers less than
ten), it is better to use `five' in this case.
On forums, the term `posting' should be eschewed in favor of the word
`post' (shorter noun, and I dislike gerunds as well).
Finally, usage of exclamation points is highly disregarded in Usenet
posts, as it places others' impressions of you as roughly equivalent to
a loud-mouthed twelve-year old kid. Your continual usage of vulgar
language and poor grasps on the basic points of politeness also add to
the impression of a brat.
[*] Well, in recent times, companies have fallen in love with the
non-traditional forms of capitalization, preferring such proper nouns as
`iPod'. The best rule of thumb to follow is to use the official
capitalization rules of the company owning the trademark.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
- 2
- newbie Threads and JDialog Hello all
I've been working with Java for one year and I'm a newbie with
threads, I have the following problem which I suppose you experts can
help:
I have a JDialog extension which I create some JTabbedPane with
some tables. This JDialog and these tables, send data to other class
which performs some calculation. Now I have a problem and I suspect
that its related with threads.
The button actionPerformed listener call a JDialog method that send
data and also "tells" the table to send its data to the calculation
class. After the table send the data, the constructor of the external
calculation programm fails. I'm listing in a reduced way my code:
In the Main (just the part related with the JDialog)
// in the declaratins:
public InputsIntegrationDialog inputIntDiag;
.
.
.
if (operationIndex == INTEGRATION){
if(inputIntDiag == null){
inputIntDiag = new InputsIntegrationDialog(this, getGraph());
}
else
inputIntDiag.setVisible(true);
The InputsIntegrationDialog class resumed:
public class InputsIntegrationDialog extends JDialog implements
ActionListener{
public InputsIntegrationDialog(Window owner, VRGraph grap1) {
super();
this.tabbedPane = new JTabbedPane();
fixedCostsTable = new IntegrationTable();
variableCostsTable = new IntegrationTable();
variableCosts = makeTextPanel(res.getString("variableCosts"));
tabbedPane.addTab("variableCosts",variableCostsTable );
Box okCancel = Box.createHorizontalBox();
ok = new JButton(res.getString("Ok"));
ok.addActionListener(this);
runBut = new JButton(res.getString("Run"));
runBut.addActionListener(this);
. ..// box layouts etc...
Container contentPane = getContentPane();
contentPane.add(tabbedPane, BorderLayout.CENTER);
contentPane.add(vertBox, BorderLayout.PAGE_END);
this.pack();
this.setVisible(true);
}
public void runOPT(){
// initialize the calculation class (hiden)
//send the data from the tables to the calculation
variableCostsTable.sendDataToOpt(data 1, data 2);
// in the line bellow the problem happens!!!!!!!!!!
solver1.setNLP(nlp1.getNLP());
}
public void actionPerformed(ActionEvent e){
System.out.println("Action: " + e.getActionCommand().toString() );
if(e.getActionCommand().toString() == "Ok"){
this.setVisible(false);
}
else if(e.getActionCommand().toString() == "Run"){
// This Line calls runOpt() and inside runOPt the crashes happen
int res = this.runOpt();
if( res1 >= 0){
JOptionPane.showMessageDialog(this,
"Optimization sucessful","Message");
}
else
JOptionPane.showMessageDialog(this,
"Optimization NOT sucessful","Error");
this.setVisible(false);
}
}
}
- 3
- Also, about JColorChooserIs it possible to edit which colors are available in a JColorChooser or
is it simpler to build my own popup window with color selections?
- 4
- JMS memory footprint sizeAnyone know what the memory footprint of JMS is?. I am trying to work
out if it is too "heavyweight" for use in a thin client.
tkx
- 5
- Transmitting strings via tcp from a windows c++ client to a Java serverHi all,
We have a C++ client which runs on Windows and that needs to transmit
char* / wchar* strings to and from a Java server.
The client should correctly handle both 'standard' languages & east
Asian
languages (i.e. using wchar).
Now, I'm sure there is a best practice for doing so , I just haven't
found it yet :-)
My best bet would be always encoding the string in UTF-8 before
sending
it via the net, but I could be wrong.
Your help will be highly appreciated.
Thanks,
Gilad
- 6
- Freelance programmer / developerHello,
I am software developer looking for freelance or Full Time work, do you
have any work that need to done.. buzz me at johnleox @ gmail.com
my skill sets:
VB,
ASP (VBScript & Javascript),
SQL Server,
Access (VBA),
Excel (VBA),
.NET(ASP.NET / C#)
Oracle &
Crystal Reports
I can work on migration projects, supporting exsisting project and
looking out for new project.
If location or place of work is not important for you then buzz..
waiting for your work.
johnleox @ gmail.com
- 7
- JTextArea size limitiing question ...I'm using a JTextArea within a JScrollPane within a JViewPort. I am
using the JTextArea to mimic a HyperTerminal like terminal emulation
interface. When I set up the JTextArea I specify the viewable rows and
columns, but since it is inside the JScrollPane it obviously can grow
"infinitely" large (and eventually throw a heap memory exception). My
desire is to not allow this, but was hoping that there was something
within Java itself to passively limit the size of the JTextArea.
Currently I use it to receive diagnostics (through a serial
communications port) from an embedded device, so during testing I could
conceivably let this run for several days (which will most certainly
induce a heap memory exception). I am also logging all of the
diagnostics to a file so I have no need for the JTextArea to grow
"infinitely" large.
So is there a way to passively limit the ultimate size of a JTextArea
that I am missing or do I have to actively determine its size and trim
it down some how (and if so, any suggestion on how to delete "old" data
in a JTextArea)?
Thanks, in advance, for any help.
- 8
- Unchecked call hashmapWhat is this with javac -Xlint??
warning: [unchecked] unchecked call to put(K,V) as a memb
er of the raw type java.util.HashMap
headers.put(key,val);
^
- 9
- Weird Static IssuePlease take a look at the following code section. In this module the
static "qt" becomes null when the constuctor is fired, very similar
code works find in other places in my program. I don't think the
QueryTools class is a problem because I can use the code elsewhere.
public class Authorization
{
static public String TABLE ="authorization";
static private String POOL_NAME = "mysql-invoice-system";
static private QueryTools qt;
static
{
System.out.println("Static Section " + POOL_NAME);
QueryTools qt = new QueryTools(POOL_NAME);
System.out.println(qt);
System.out.println("Static Section End " + POOL_NAME);
}
public Authorization()
{
System.out.println("Authorization Constructor");
System.out.println("QT=" + qt);
}
Here is the output from Netbeans:
run:
Static Section mysql-invoice-system
com.ciorent.HFCConnectionPool.QueryTools@18e2b22
Static Section End mysql-invoice-system
Authorization Constructor
QT=null
Here is the calling code:
Authorization a = new Authorization();
try
{
a.createAccount("email***@***.com", "test4200", 10000);
}
catch (Exception e)
{
System.out.println(e);
}
System.exit(1);
I am going to bet this is something simple that I am missing, hopefully
someone will be able to point out my error.
Thanks
HFC
- 10
- 11
- prohibited methodwhat does it mean when we say ,
in EJB session bean
"The bean instance calls a prohibited method of its session context."
what does it mean by prohibited method ? who prohibits ? how can we
set this prohibition ?
thanks
- 12
- have troulbe when learn java tutorial's network socket partHi everyone:
Try fewest word: from Java Turotial->Custom Networking->All About
Sockets->Reading from and Writing to a socket, the following program:
import java.io.*;
import java.net.*;
public class EchoClient {
public static void main(String[] args) throws IOException {
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
echoSocket = new Socket("taranis", 7);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: taranis.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for "
+ "the connection to: taranis.");
System.exit(1);
}
BufferedReader stdIn = new BufferedReader(
new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
System.out.println("echo: " + in.readLine());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}
}
But it says "Don't know about host: taranis". If I change it to my
computer's name, it says "Couldn't get I/O for the connection to:
taranis.";
So how can I open echo service on a computer? Thanks.
- 13
- JTable cell editor update several columnsI have a JTable with multiple columns line
let's say : name, cat, subcat, lang
I would like a cell editor on name ;cat , subcat and lang read only
when I edit name whenever I choose a mame that belongs to
cat,subcat,lang the cat,subcat,lang cells are updated .....
tanks a lot
patrick
jdk1.6.0_02/linux
- 14
- Running a bat file from a Tomcat servlet using the exec commandI cannot get a Tomcat servlet to execute a Windows Bat file.
Is there a particular setting in the catalina.policy file that I need
to change?
Here is a code snippet of the call:
Runtime load = Runtime.getRuntime();
Process process = load.exec("cmd.exe /c start copyFiles.bat", null,
new File("C:\\Tomcat 5.0\\webapps\\myApp\\files"));
Thanks for any help.
-Chris
- 15
- Using JComponent.getGraphics() in Swing for incremental paintingHello,
I have read many posts and articles saying "don't ever use
getGraphics() in Swing JComponents... always use paintComponent()!" I
understand the motivation for such statements: the paintComponent()
method should be used to implement painting, in order to ensure
correct behavior in all situations.
However, my question is: is it OK, from within an event handler, to
paint using getGraphics() PURELY AS AN OPTIMIZATION, AS LONG AS
paintComponent() does the right thing?
An example:
class MyComponent extends JComponent
{
ArrayList thingsToPaint=new ArrayList();
public void mySwingEventHandler(SomeEvent e)
{
//update thingsToPaint so that paintComponent
//works correctly
thingsToPaint.add(somethingNewToPaint);
//try painting directly
Graphics g = getGraphics();
if(g != null)
{
//we have a graphics, so paint the new
//thing directly.
somethingNewToPaint.drawOn(g);
g.dispose();
}
else
{
//No graphics object available... so just
//call repaint().
repaint();
}
}
public void paintComponent(Graphics g)
{
//paint everything
int i, size = thingsToPaint.size();
for(i=0; i < size; ++i)
{
((ThingToPaint) thingsToPaint.get(i)).drawOn(g);
}
}
};
I actually have a good reason for doing this. I am writing a simple
image manipulation program, and I need to implement a rectanglar
selection facility. In order to accomplish this, I need to listen to
mouseDragged events and repaint the rectangle on the image at each new
position. Swing forces you to re-paint the entire image each time
(i.e. no incremental updates), which is annoyingly slow for this
particular problem. And I don't want to turn off double buffering.
If I use getGraphics() directly (as in the example above), I can just
update a tiny section of the image, and it is blindingly fast and
smooth. I have tested this, and it works wonderfully in my limited
tests. But I don't want to do it if it will be problematic down the
line.
So, is it OK to use getGraphics() if the full repainting functionality
is available in paintComponent()? Or is there some other reason not to
use getGraphics()?
Thanks,
Mike Carrato
|
|
|