| Technique for loading user defined modules |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- How can I make my applet call another Web page?Hi All,
Would anyone know a way to have an applet call another Web page so
that, after the new page is loaded, if I hit the back button then I go
back to the page where the applet is at?
I don't need to know about button action events or about layout
managers or anything like that, just the URL processing code, or a
good reference.
Thank you,
S.
- 3
- read gps bluettoth on applet pda - javacommHi all,
I'm a student..
I wrote an applet for PC that reads GPS data from serial port (using
javacomm)....
I would like to have the same applet on my pda, an IPAQ h1940 with bluetooth
gps receiver ....
I'm using javacomm and driver for pda found on www.teilo.net , I followed
the steps of the site, but it doesn't work... :-(
any questions:
- where have I to put javax.comm.properties, CESerial.jar and comm.jar ???
in which directory?
- how can I add the directory containing the javax.comm.properties, and the
paths to both jar files to my classpath? modifying the registry? which key?
(I searched in the registry but I didn't find none of java, path, classpath
etc...)
- if I want to read bluettoth data, I have to read a virtual serial port
(COM8?), right?
thanks all!
gp
- 3
- Singleton QuestionOn 1 Jul 2004 05:10:57 -0700, email***@***.com (Dave Monroe)
wrote or quoted :
>What's GoF?
see http://mindprod.com/jgloss/gof.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
- 3
- Two column list with JOptionPaneYes, this is a homework question. My assignment is:
Modify the mortgage program using a graphical user interface to allow the
user to input the amount of a mortgage and then select from a menu of
mortgage loans: 7 year at 5.35%, 15 year at 5.5 %, and 30 year at 5.75%.
Use an array for the different loans. Display the mortgage payment amount.
Then, list the loan balance and interest paid for each payment over the term
of the loan. Allow the user to loop back and enter a new amount and make a
new selection, or quit. Insert comments in the program to document the
program.
I have been able to complete all of it except the part about list the loan
balance and interest paid. I used JOptionPane to do all the graphical user
interface and the menu of mortgages (see code below), but can't seem to come
up with a way to display the information in JOptionPane. If there is
another way that will work please point me in the right direction.
private static double option(double inputAmount)
{
// declares variables
double amount = inputAmount;
double monthlyPayment = 0.0;
boolean done = false;
// loop while not done
while (!done)
{
// declare and set size of/initializes array
double loanInfo[][] = new double [][] {{5.35, 5.5, 5.75},{7,15,30}};
// creates an array to hold the options
String smallList[] = {"7 year at 5.35%","15 year at 5.5%","30 year at
5.75%"};
String option = (String)JOptionPane.showInputDialog(null,"Which loan
option?","Options",JOptionPane.QUESTION_MESSAGE,null,smallList,smallList[smallList.length-1]);
for(int count = 0; count < smallList.length; count++)
{
// checks answers for match and sends info to calculate payment
if(option == smallList[count])
{
// calls method to calculate the monthly payment
monthlyPayment = calculationsPayment(amount, loanInfo[0][count],
loanInfo[1][count]);
done = true;
}
}
}
return monthlyPayment;
}
--
Jennifer Szonye
- 7
- Help me!! Why java is so popularrad dog58c wrote:
>
> How can it negative? I'm not saying you're wrong, but how can any
> byte-coded language outperform a binary language if they are doing the
> same thing? It can't, because you have to convert the byte code to
> the native binary stream before you can execute it. So I'm thinking
> you mean certain algorithms are more efficiently handled by the JVM?
> Please elucidate -- I heard someone say Java memory management now
> exceeds C and I thought it was an interesting notion and probably
> related to some ingenius optimizations in memory mgt algorithms,
> though I honestly don't know.
Garbage collection can have an advantage in multi threaded applications,
and in Java we can have exact c. The JIT can optimise (and inline) the
code you are actually using today. I have code where part of computation
is represented by an interface and the implementation selected depends
on the data being processed.
In a compiled language you can't optimise across the interface call
whereas with Java you can. Even better you can generate byte code at run
time (e.g. compile an expression typed by the user) and then the JIT can
compile that to machine code and if it is simple enough inline it.
Java can devirtualise a method call if at some point you happen to have
only one implementation in the JVM.
> No doubt, and Java's fine messaging implementation and rich set of
> protocol support, eg, makes it a good vehicle for such things. A
> service I'm fine with -- a utility I need to fire up over and over,
> not so fine with that. I wouldn't write that in Java.
If it is something you fire up manually then the startup time isn't
important (takes you longer to type the command). If it is run from a
script, then it rather depends on the script (i.e. if the script system
maintains a JVM to execute little tasks in, the startup time can again
be negligible).
>
> At one time there was a Java compiler that let you go from Java
> to .EXE. I used it quite a bit, although the .EXEs it generated were
> pretty fat for the functionalit they implemented. Then again Java's
> not about creating .EXEs, so that didn't surprise me.
Such things still exist but have always struggled to match the
performance of regular JVMs.
> How does one get Java to run faster than a compiled language?
Take advantage of its strength, the ability to compile dynamically
loaded (or created) code and optimise the whole without regard for
module boundaries. Also take advantage of garbage collection --- its
performance has dramatically improved in recent years.
Mark Thornton
- 8
- Packing Resource-Based App Into a .JARI have an application which uses outside data files. That is, it has
lines of code like this:
DataReader.loadFile("data/MyFile.dat");
Right now the app is just a bunch of .class files and I start it on
the command line from the appropriate directory to ensure that the
data files can be found.
But I want to package the app as a .jar (a .jar which includes the
data files) and be able to run the .jar from any directory. That is,
when it's running, java should search for the data files relative to
the .jar root, rather than relative to the root where the process was
started.
How can I do this?
Thanks,
cpp
- 8
- translate fitsG0ldmark Industries, Inc ( G D K I )
THIS ST()CK IS E><TREMELY U_NDERVA_LUED
Huge Advert|sing Campaign this week!
Breakout Forecast for July, 2006
Cu_rrent Price: $7.02 (5 days ago was $5)
Sh0rt Term Price Target: $12.00
Rec0mmendati0n: Str0ng Buy
RECENT H0T NEWS released MUST READ ACT NOW
LOS ANGELES & VANCOUVER, British Columbia---(July 5, 2006)
Goldmark Industries, Inc. ( G D K I - News) is excited to announce
that the Company is embarking into a new business direction. The
Company is making an aggressive move into the multi-billion-dollar
Urban Entertainment industry. The Hip-Hop Entertainment industry
generates several billion dollars per year in product sales with
an estimated consumer-based purchasing power well into the hundreds
of billions of dollars and topping over one trillion worldwide.
About Goldmark Industries, Inc ( G D K I ):
Goldmark Industries is preparing to stand at the forefront of
the Hip Hop consumer market, offering a wide range of urban
entertainment services in Music, Feature Films, Television,
Home Video/DVD and Major Events
Compaq Diag. viewing SCSI
fast spelling checks
sda named numbering
FFSYes. include: UDFCDROM NFS
refer
typically
Business Desktop Education
Lite. Winner:
thisswap via vnode
intend soit
extracted multiuser went planned
youwill gathered istime asa
Home Hobby
average meeting passed. realtime:
code Select extended
toavoid incurring working
prepared restoring
/var/swap thatisnumbering figure going /u.
macppc zaurus andcats
Mrpm: qWrite
drop frames
removed code.
wdb thekernel
thefile. creating /var/swap thatis
offset
mountyour above.You procedure plugging
modifying it: wd
feed needed listed above:
probably outside unable fetch
configure
work. clock proven most
shareware
Can access
newone theblocks
unknown j: aswell curious
length.RM missing
BIOSs abilityto
submit
buggy chipsets
Contents. Using OpenBSDs
WatchdogwdEnter Command Show reinitGraph: Creates
gathered istime asa /dev/wdm
numbering figure going
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 9
- Outsourcing to India and ChinaPhillip Lord <email***@***.com> wrote in message news:<email***@***.com>...
> >>>>> "Loco" == Loco Pollo <email***@***.com> writes:
>
> >> >this is anti free trade and ultimately anti freedom.
> >>
> >> Free trade is not necessarily a good thing.
>
> Loco> no but many good can come of it.
>
> >> First it encourages shipping goods all over the planet that could
> >> have been produced locally. This wastes fuel and pollutes the
> >> atmosphere.
>
> Loco> in a truly market economy, it wouldn't happen unless it is
> Loco> cost effective. this would include the cost of pollution.
>
> No it wouldn't. The market economy fails to work for any commodity
> where the cost of charging for that commodity either outweighs the
> value of that commodity, or worse, there is no way to charge for a
> commodity.
>
> For example, I like hill walking. In the UK there are lots of
> hills. Its not possible to charge for them because building a large
> fence around the for example, the 150 miles of the peninnes would cost
> a massive amount. Worse there is a legal "right to roam" which
> effectively stops the land owners from doing this anyway.
imho what your talkin bout has nothin to do with a free market. if
there's no market for it the market wouldn't be there. if there is a
need a market would self create itself. in your example, no company
would try to charge you for the trails you use if there was no way to
make $ off of it(of course there is and they are, hiking boots from
texas, rain jacket made in china, etc..). the destruction of nature
caused by hikers has more to do with govt and user obligations than
with free trade. actually none of that example has to do with free
trade.
> Of course in the US, it would be a different matter, as you would just
> build a gate across the road leading too the hills, which would
> effectively block all access.
actually we got what's called national parks where the govt pays for
its upkeep subsidized by entry fees. i'm guessing our national park
system has 100s of millions of people accessing them per yr and
preserves what would otherwise be developed.
> >> It enables multinationals to exploit workers by threatening to
> >> move to where labour and environmental laws are laxest.
>
> Loco> multinationals are no different than national companies. if a
> Loco> country "can" manage a national company, i see no reason why
> Loco> the world can't manage a multinational.
>
> We don't have a world government. The only "regulatory" bodies for
> multinationals for some reason seem to work in the interest of the
> multinationals, or more accurately the interest of those who own the
> multinationals rather than the population at large.
we do have a world govt. there are people who specialize in
international laws. yes multinationals have way too much power,
however, this isn't because of free trade. its because we as a species
are too greedy and corrupt.
we have everything we need to create a paradise but none of the social
maturity to accomplish it.
- 9
- security-roles: application.xml vs web.xmlHi,
does anybody know how a webmodule behaves when It is assemble in an ear
containing the web module and I include security-roles in both the
application.xml and web.xml? I have been browsing both the j2ee and servlet
specs, but I haven't found any description of mandated behaviour. I have
tested a little with sun one appserver7. This appserver seems to ignore the
security-roles defined in the web.xml. What's more, don't mentioning
security-roles in the application.xml and only use the web.xml for mapping
security-roles breaks the login process.
Does all this mean that security-roles in the web.xml file can only be used
for standalone web applications and not for web modules who are part of an
ear?
Cheers
Jan
- 9
- Forged posts (was: Re: operator overloading)Someone impersonating Lew <email***@***.com> writes:
> Those aren't domain goals, those are church programmes, and they
> don't matter a jot to the cheesecake.
[ More dissociated-press text elided. ]
Has anyone else complained to the site where these posts are
being injected or does Lew enjoy having a special fan?
Regards,
Patrick
------------------------------------------------------------------------
S P Engineering, Inc. | Large scale, mission-critical, distributed OO
| systems design and implementation.
email***@***.com | (C++, Java, Common Lisp, Jini, middleware, SOA)
- 9
- Bug in IE with KB896727Recently we installed the MS05-038 as part of Windows Update. After this we
found out that our Code behind HTML application created in VJ++ is not
loading properly in IE 6 browser. We chekced all the Security settings and
they seem to work fine.
If we uninstall the Hotfix update ( KB896727 ) the application again loads
properly. Is there any work around for this issue. This is very critical.
Thanx
- 10
- View large file
I need to view a large file. If I use class JTextArea will it load
whole file into RAM or load one in portions?
I have read I must use ZoneView for this purpose. How can I use it?
Thanks in advance
- 10
- String concatenation versus StringBufferCan someone deny or confirm that the latest sdks convert code like
"abc" + "def" + "ghi"
into the appropiate StringBuffer code
new StringBuffer( "abc" ).append( "def" ).append( "ghi" )
automatically? Or is this some dream I had?
Thanks!
- 11
- ASP.NET vs J2EE - Scalability and SpeedRegarding this pieces of information:
65% of the Fortune 500 companies
80% of the top US healthcare companies
75% of commercial banks worldwide
90% of the top commercial banks in the US
67% of the world's largest banks use IBM messaging servers
15 of the top Wall Street brokerage firms
7 of the 8 largest US telecommunications companies
That's true. But what I can understand about that figure was -
Those businesses started using Internet and Computer Networking
technologies times ago. It happens before Microsoft started to get
strong. I am working in a pharmaceutical company in US and we are using
lots of IBM products. We are trying very hard to stop using them and
turn our techology to Microsoft. Off course, personnally - I hate
microsoft - I dont' feel fun when I use any one of micrsoft product.
But in the business term - Microsoft products are qualified. Cheap to
support and run - some tools are never over kill such as SQL server. We
are using Oracle but I found only SQL server that just more than enough
and a lot cheaper to run (cost of DBA and Programmer, etc).
Webspere? Naaa .... we have been using Webspere when we started having
our own Web site and Intranet sites. Then we changed to Coldfusion in
the last 5 years. I found those suck! Cost too much money - when
Microsoft IIS5 or 6 are free also .NET - so, why not!!!!
Sure - a lot of Banks use J2EE - same reason! They rally want to stop
using it but they cannot because everybody started with J2EE and know
J2EE better than anything else!!!
Sad but true!
- 14
- Is eclipse broken?
--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
I'v got a 5.1 RELEASE box. plenty of disk space and memory. Recently
rebuildt from a complete cvsup (cvsup, make buildworld, make installworld,
pkgdb, portupgrade)
=3D=3D UNAME =3D=3D
berkeley% uname -a
FreeBSD berkeley.mooseriver.com 5.1-RELEASE-p11 FreeBSD 5.1-RELEASE-p11 #0:=
Sat Dec 13 01:17:51 PST 2003 email***@***.com:/usr/obj/usr=
/src/sys/BERKELEY i386
berkeley%=20
=3D=3D MAKEFILE =3D=3D
New ports collection makefile for: eclipse
# Date created: March 7, 2003
#
# $FreeBSD: ports/java/eclipse/Makefile,v 1.15 2003/12/04 10:26:10 olgeni E=
xp $
#
PORTNAME=3D eclipse
PORTVERSION=3D 2.1.2
so I do the following :
cd /usr/ports/java/eclipse
make install clean
and I get :
<bunch of comple messages> then=20
=3D=3D=3D> Linking eclipse.
/bin/mkdir -p plugins/platform-launcher/bin/freebsd/gtk
/usr/local/bin/ccache g++ -o plugins/platform-launcher/bin/freebsd/gtk/ecli=
pse plugins/platform-launcher/library/gtk/../eclipse.o plugins/platform-lau=
ncher/library/gtk/../eclipseUtil.o plugins/platform-launcher/library/gtk/ec=
lipseGtk.o `pkg-config --libs gtk+-2.0`
/usr/bin/ld: warning: libatk-1.0.so.200, needed by /usr/X11R6/lib/libgtk-x1=
1-2.0.so, may conflict with libatk-1.0.so.400
=3D=3D=3D> Compiling Java sources.
ant -Dos=3Dfreebsd -Dws=3Dgtk -f build.xml compile
/usr/libexec/ld-elf.so.1: /usr/lib/libm.so.2: Undefined symbol "__fpclassif=
yd"
*** Error code 1
Stop in /usr/ports/java/eclipse/work.
*** Error code 1
is anyone else getting this?
Josef
--=20
Josef Grosch | Another day closer to a | FreeBSD 5.1
email***@***.com | Micro$oft free world | Berkeley, Ca.
--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
iD8DBQE/2ufUy8prLS1GYSERAvxvAKCYaR1F5IqkE8fzEx5uqdP79BhLtQCg6e8Q
b9/KxeK0nzfbwfFL0Ptwo+o=
=M5R6
-----END PGP SIGNATURE-----
--xHFwDpU9dbj6ez1V--
|
| Author |
Message |
Per E

|
Posted: 2006-5-24 2:14:00 |
Top |
java-programmer, Technique for loading user defined modules
Dear all,
I am writing a program to do data analysis. I want the user to be able to
extend the functionality of the software by adding their own "analysis
modules" but am unsure how to go about this. From the user perspective, I
would like the application to look in a particular directory (or along some
user defined search path) for modules (classes) with the appropriate
behaviour and make these modules (classes) available through the program's
user interface.
It must be possible to complile these modules without access to the source
code for the entire data analysis program.
Can anyone give me some hints on which direction I should go in to handle
this issue?
Thanks in advance,
Per
|
| |
|
| |
 |
Bjorn Abelli

|
Posted: 2006-5-24 3:43:00 |
Top |
java-programmer >> Technique for loading user defined modules
"Per E" wrote...
> I am writing a program to do data analysis.
> I want the user to be able to extend the functionality
> of the software by adding their own "analysis modules" but am unsure how
> to go about this.
> From the user perspective, I would like the
> application to look in a particular directory
> (or along some user defined search path) for modules
> (classes) with the appropriate behaviour and make these
> modules (classes) available through the program's user interface.
>
> It must be possible to complile these modules without
> access to the source code for the entire data analysis
> program.
>
> Can anyone give me some hints on which direction I should
> go in to handle this issue?
This sounds pretty much like some kind of plug-in, or add-in technique.
There are lots of possible approaches to this, but in my experience the
easiest path to do this is by Reflection.
A couple of years ago I made a generic ad-hoc database query application,
which worked against any type of database, as long as there was a type 4
driver along. Then I just dropped the driver into a specific directory, and
the user simply added the driver in the applications configuration (via its
GUI).
This sounds pretty similar.
What you then need to define is a public interface in order to make the
plug-ins "pluggable". A simple example could just be:
------------------------------------
package xyz;
public interface PlugIn
{
Collection run(Collection data);
}
------------------------------------
..i.e. that the application provides some data through some Collection, and
returns the result in another Collection of some type, that your application
then presents in a described manner.
This interface doesn't even need to be in source code form, but just as a
bytecode .class-file.
The part of then getting hold of the "plugged in" class, is then easy or
easier. Just see to that the class is on the classpath when you start the
application, and provide the classname in some way:
Class c = Class.forName("MyPlugIn");
PlugIn p = c.newInstance();
Collection outdata = p.run(indata);
This was just an example, as I mentioned that there are several other
alternatives too.
How complex the plug-in interface has to be is up to you, and what you want
the plugins to be able to do.
There could also be a question of using the ClassLoader depending on how
advanced you want to get, and how you package your application.
But I hope this is has provided a start for you.
/// Bjorn A
Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
|
| |
|
| |
 |
Ian Shef

|
Posted: 2006-5-24 3:49:00 |
Top |
java-programmer >> Technique for loading user defined modules
"Per E" <email***@***.com> wrote in
news:UhIcg.1555$email***@***.com:
> Dear all,
>
> I am writing a program to do data analysis. I want the user to be able
> to extend the functionality of the software by adding their own
> "analysis modules" but am unsure how to go about this. From the user
> perspective, I would like the application to look in a particular
> directory (or along some user defined search path) for modules (classes)
> with the appropriate behaviour and make these modules (classes)
> available through the program's user interface.
>
> It must be possible to complile these modules without access to the
> source code for the entire data analysis program.
>
> Can anyone give me some hints on which direction I should go in to
> handle this issue?
<snip>
I suggest that you pick up a copy of
"Java Reflection in Action" (In Action series) by Ira R. Forman and Nate
Forman
Basically, you are going to need to:
1) Compile the source code. Either the user does this, or your data
analysis program does it either via java.lang.Runtime.exec (the referenced
book has code showing how to do this) or by using the built-in comppiler
features of a recent version of Java (1.5? 1.6?).
2) Use reflection to dynamically load the class file from step 1.
I don't think that you do need to provide source code for any part of your
data analysis program. The user's modules will need to implement some
Interface that you define.
Disclaimer: I have read the book and liked it. I have no other connection
with the book, its publisher, its authors, or a bookstore. I have not yet
implemented any of the ideas presented in the book.
--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *
|
| |
|
| |
 |
Thomas Fritsch

|
Posted: 2006-5-24 7:11:00 |
Top |
java-programmer >> Technique for loading user defined modules
"Bjorn Abelli" <email***@***.com> wrote:
> This sounds pretty much like some kind of plug-in, or add-in technique.
> There are lots of possible approaches to this, but in my experience the
> easiest path to do this is by Reflection.
[...]
> What you then need to define is a public interface in order to make the
> plug-ins "pluggable". A simple example could just be:
>
> ------------------------------------
>
> package xyz;
>
> public interface PlugIn
> {
> Collection run(Collection data);
> }
>
> ------------------------------------
>
[...]
> The part of then getting hold of the "plugged in" class, is then easy or
> easier. Just see to that the class is on the classpath when you start the
> application, and provide the classname in some way:
>
> Class c = Class.forName("MyPlugIn");
> PlugIn p = c.newInstance();
> Collection outdata = p.run(indata);
>
[...]
Java offers a generic service-registry. Using it can simplifiy your approach
even more. The following code-snippet is enough for loading all Plugin
implementations found in all jar files of your classpath:
import java.util.Iterator;
import javax.imageio.spi.ServiceRegistry;
Class c = Plugin.class; // your interface class
Iterator iter = ServiceRegistry.lookupProviders(c, c.getClassLoader());
while (iter.hasNext()) {
Plugin plugin = (Plugin) iter.next();
... // add plugin to your application's plugin list
}
In order for this to work each jar-file has to specify which implementations
of the Plugin interface it provides. In your case (interface xyz.Plugin) the
jar has to contain a file
/META-INF/services/xyz.Plugin
This file is a plain text file containing the fully qualified class names
(one per line) of the concrete plugin implementations contained in this jar.
See also <http://java.sun.com/.../j2se/1.4.2/docs/guide/jar/jar.html#Service
Provider> for more info about it.
By the way: Java itself uses this mechanism widely (for image decoders,
image encoders, character encodings, sound decoders, ...).
--
"TFritsch$t-online:de".replace(':','.').replace('$','@')
|
| |
|
| |
 |
Thomas Fritsch

|
Posted: 2006-5-24 17:40:00 |
Top |
java-programmer >> Technique for loading user defined modules
Thomas Fritsch wrote:
> See also <http://java.sun.com/.../j2se/1.4.2/docs/guide/jar/jar.html#Service
> Provider> for more info about it.
Arrgh, I meant
<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider>
--
Thomas
|
| |
|
| |
 |
Arvind

|
Posted: 2006-5-24 23:28:00 |
Top |
java-programmer >> Technique for loading user defined modules
Per E wrote:
> Dear all,
>
> I am writing a program to do data analysis. I want the user to be able to
> extend the functionality of the software by adding their own "analysis
> modules" but am unsure how to go about this. From the user perspective, I
> would like the application to look in a particular directory (or along some
> user defined search path) for modules (classes) with the appropriate
> behaviour and make these modules (classes) available through the program's
> user interface.
>
> It must be possible to complile these modules without access to the source
> code for the entire data analysis program.
>
> Can anyone give me some hints on which direction I should go in to handle
> this issue?
>
> Thanks in advance,
> Per
Just a note, tangential nonetheless, since these deployed plugin jars
are essentially 'hot-deploys' i.e. would not participate via a build
and get bundled with the mainstream, version management and backups
become the responsibility of the users.
|
| |
|
| |
 |
Dale King

|
Posted: 2006-5-26 3:00:00 |
Top |
java-programmer >> Technique for loading user defined modules
Thomas Fritsch wrote:
> [...]
> Java offers a generic service-registry. Using it can simplifiy your approach
> even more. The following code-snippet is enough for loading all Plugin
> implementations found in all jar files of your classpath:
Allow me to be the voice of security here...
There are security concerns here when you are letting other people's
code run within your appplication. It's not that you shouldn't do it,
but there are security concerns to worry about both for your application
and for your user's privacy and security and you should take the steps
to handle it.
While the topic may have been about allowing users to write their own
plug-ins, the fact is that you should consider the possibility of third
party plug-ins being made available for download. Then you have to
consider the possibility of malicious code in those plug-ins.
You should not have the plug-in jars being on your applications initial
class path. Doing that gives the plug-in the same rights as your
application.
You should have the user specify where the plug-in jars are, either as a
list of jars or a directory where the jars are. You can create your own
class loader pointing to the specific jars using URLClassLoader (they
have a URL format for jars, see the Javadocs for JarUrlConnection).
You can then specify what the plug-in is allowed to do and what classes
of your application it can access. By default it should be sandboxed to
not do much at all.
You should have a mechanism to allow a plug-in to get more access, but
only if it is signed, you present the certificate to the user, and ask
them if they want to allow it.
See the seucrity section of the Java Tutorial.
--
Dale King
|
| |
|
| |
 |
Chris Smith

|
Posted: 2006-5-26 4:13:00 |
Top |
java-programmer >> Technique for loading user defined modules
<Dale King <"DaleWKing [at]gmail [dot] com">> wrote:
> Allow me to be the voice of security here...
>
> There are security concerns here when you are letting other people's
> code run within your appplication. It's not that you shouldn't do it,
> but there are security concerns to worry about both for your application
> and for your user's privacy and security and you should take the steps
> to handle it.
[...]
Incidentally, I wrote the following quite some time (years) ago. I
didn't look over it to see how valid it is, but it expands on some of
these concepts in detail, including ways to handle security managers for
plugins:
> http://www.javamoderator.org/Java%20White%20Papers/05%20-%20Miscellaneous/Using%20Reflection%2C%20Classloaders%2C%20and%20Plug-ins.doc
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
|
| |
|
| |
 |
Per E

|
Posted: 2006-5-28 2:44:00 |
Top |
java-programmer >> Technique for loading user defined modules
Thank you all for the bits and pieces of information you have supplied. I
think I have a good over all understanding of the problem now and different
ways to solve it.
Thanks again.
Per
"Chris Smith" <email***@***.com> wrote in message
news:email***@***.com...
> <Dale King <"DaleWKing [at]gmail [dot] com">> wrote:
>> Allow me to be the voice of security here...
>>
>> There are security concerns here when you are letting other people's
>> code run within your appplication. It's not that you shouldn't do it,
>> but there are security concerns to worry about both for your application
>> and for your user's privacy and security and you should take the steps
>> to handle it.
>
> [...]
>
> Incidentally, I wrote the following quite some time (years) ago. I
> didn't look over it to see how valid it is, but it expands on some of
> these concepts in detail, including ways to handle security managers for
> plugins:
>
>> http://www.javamoderator.org/Java%20White%20Papers/05%20-%20Miscellaneous/Using%20Reflection%2C%20Classloaders%2C%20and%20Plug-ins.doc
>
> --
> www.designacourse.com
> The Easiest Way To Train Anyone... Anywhere.
>
> Chris Smith - Lead Software Developer/Technical Trainer
> MindIQ Corporation
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- another design question, abstract static methods...so here is another general question about java...
why can't you declare an abstract static method.
i can envision the case (indeed i have experienced the case) where one
would want an abstracct superclass, with an abstract method such that all
subclasses that implement this method make that method static.
basically, the abstract class declares an abstract method that should be
static for all implementations (for example a factory method).
this isn't allowed in java, and in the language specification, there is no
reason given as to why. it is just simply stated in a single sentence
that an abstract method cannot be static. (or it turns out even the
implemented method).
can anyone explain why this isn't allowed? (i.e. give an example that
shows the flaws that can arise from such a situation).
thanks much!
murat
--
Murat Tasan
email***@***.com
email***@***.com
email***@***.com
http://genomics.cwru.edu
- 2
- Setting namespaces in DOMHi all,
I'm trying to construct an XML (SOAP) document, with a number of namespaces.
DOM provides Document.createElementNS(), which can be used to add the
namespace in the particular element. However, I often get the case where
the namespace definition is repeated in multiple sibling elements, while
it would be a lot simpler (cleaner?) to define the namespace only once
at a higher level.
I tried using
document.getRootElement().setAttribute("xmlns:xsd", XSD_NS);
but, even though the document.toString() shows the correct xmlns:xsd
attribute in the root node, it is still repeated in the lower level
elements.
Does anyone have any idea of how the DOM decides when to "roll-up" a
namespace definition to a higher level? Or how to tell it to?
I'm talking about the difference between:
<rootnode>
<childnode xsi:type="xsd:int" xmlns:xsi="http://w3c.blah"/>
<childnode xsi:type="xsd:int" xmlns:xsi="http://w3c.blah"/>
<childnode xsi:type="xsd:int" xmlns:xsi="http://w3c.blah"/>
</rootnode>
and
<rootnode xmlns:xsi="http://w3c.blah">
<childnode xsi:type="xsd:int"/>
<childnode xsi:type="xsd:int"/>
<childnode xsi:type="xsd:int"/>
</rootnode>
Many thanks.
Rogan
- 3
- Problem with browser tabs and sessionsI have a application make in jsp tomcat 4.1.
the customer fill some forms and the data in store in session.
The problem is that if customer open new tab(ie or firefox) and see
info another product when he change for tab initial and submit, the
system will rise error because some data of session was changed.
How i can fix it ?
I need each tab have your new session, there are any config in tomcat
for make it ?
thanks a lot
- 4
- Bug in childrenNames() api for Preference class?Hi,
The following code trhrows an Illegal Argument Exception.
import java.uitl.prefs.*;
try{
String xyz[] = (Preferences.userRoot()).childrenNames();
} catch (Exception e) {
e.printStackTrace();
}
The exception caught is :
java.lang.IllegalArgumentException: String length must be a multiple
of four.
at java.util.prefs.Base64.base64ToByteArray(Base64.java:134)
at java.util.prefs.Base64.altBase64ToByteArray(Base64.java:126)
at java.util.prefs.FileSystemPreferences.nodeName(FileSystemPreferences.java:859)
at java.util.prefs.FileSystemPreferences.access$1900(FileSystemPreferences.java:33)
at java.util.prefs.FileSystemPreferences$10.run(FileSystemPreferences.java:640)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.prefs.FileSystemPreferences.childrenNamesSpi(FileSystemPreferences.java:632)
at java.util.prefs.AbstractPreferences.childrenNames(AbstractPreferences.java:699)
at test.main(test.java:9)
Is this a BUG in java?
My requirement is that I have many NODES under the root node of user
preferences(userRoot).I want the list of nodes, for futher
processing.How do i retrieve them?
Please help.
(Also send a cc to my email:email***@***.com)
Thanks,
Prakash.
- 5
- No call for Ada (was Announcing new scripting/prototyping language)Josh Sebastian wrote:
> Maybe you just weren't very good at C++ templates. I don't mean to be
> insulting, but personal preferences do play a huge roll here. Unless
> someone can prove Ada's generics are Turing-complete, though (a quick
> google doesn't turn up anything), I'd say that we'll have to call C++
> templates more powerful.
Turing completeness is only one measure of power. And not a very
good one for measuring different systems of templates. If you use
templates for any sort of computational programming beyond some
very simple things you are stretching the rubber band beyond its
limit.
--
Thomas.
- 6
- Question concerning jh_manifestHi Matthew,
I have further researched this problem. To me it seems a (not too
trivial) bug in jh_manifest. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=489214. Maybe better to
discuss the topic there to keep this list clean...
Cheers,
Florian
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 7
- Java and assemblyHI everyone,
Is there a possible relation between Java and assembly language like ther
is with JNI?
--
Thanks for your attention.
Jean Pierre Daviau
- 8
- directory questionI have a file named "main.ini" in the directory of jar (self-executable
package)
When I run jar from its directory all ok
When I run jar from another directory it cannot found "main.ini"
I open "main.ini" with
InputStream is = new FileInputStream("main.ini");
but I understand I must open it with
InputStream is = new FileInputStream(getDirectoryOfJavaProgram() +
"main.ini");
can you implement
getDirectoryOfJavaProgram()???
thanks!
- 9
- 10
- BUG in jre that work fine in jview - mouseEventAnyone come up with an answer to this?
I'm having the same problem, I've created
a "skin" slider control in J++, when I use
Microsoft it returns coordinates relative to
the slider control, when I use Sun it's relative
to the applet, the listener class and handler is
within the slider control class.
I've found LOTS of examples online that are setup
just like my code, and they all, including Sun's
documentation (as well as Microsoft's) say it should
be relative to the control.
Thanks,
EdisonCPP
Nir melamoud wrote:
> Hi,
>
> Can anyone please explain me how can i write an application that
> use the mouseEvent.getX(),mouseEvent.getY() functions on both sun jre
> and microsoft jview without checking for the interpreter origin ?
>
> In jview the function return the coordinate relative to the component
top
> left point = (0,0)
>
> In jre it return in mouseEnter relative to the beginning of the
screen (not
> even the window)
> and in mouseExit relative to the component top left point ?
>
> It look like a bug in jre, because sun help support microsoft version
-
> relative to the source component.
>
> Does anyone know how can i translate these points so it will work on
both
> jview and jre ?
>
> here is a small code example: try to enter and exit the frame and see
the
> printout, try it on jre and jview
>
> import java.awt.* ;
> import java.awt.event.* ;
> import java.io.*;
> import jclass.bwt.*;
>
> class mouse extends Frame {
> public static void main(String arg[]) {
> mouse m = new mouse("Mouse Test") ;
> m.setSize(400,300) ;
> m.setVisible(true);
> }
>
> public mouse(String s) {
> super(s) ;
> enableEvents(AWTEvent.MOUSE_EVENT_MASK);
> }
>
> public void processMouseEvent(MouseEvent m) {
> System.err.println("x,y = " + m.getX() + "," + m.getY()) ;
> }
> }
- 11
- 12
- Timouts for RMIHi all,
i know there are several posts, and a google search found lots of hits on this topic.
My Problem is: Nothing works...
My intension is very simple:
Use Rmi to transmit data from a client to a server.
In principle it works fine. My Problem are the RMI-timeouts. They are too long.
I have to take into account that some "unclever Guy" pulled the network plug.
My Client still wants to send data to the Server (call a servermethod via rmi).
I call the method and this thread is blocked. Fine. Network is still broken.
Depending on the OS of the client (windows, linux) the Timeouts vary.
In Windows its about 20 Sec => Exception. In Linux? Years? It looks like the method never returns
with an error.
Is there a way to set the timeout for calling a method.
(The time after the methodcall returns an error when the server isn't reachable)
I tried:
a) Setting the RMISocketFactory creating my own clientsockets having the SoTimeout set... didnt work.
b) setting the Systems sun.rmi.transport.connectionTimeout ... didnt work
Hope you can help me.
- 13
- Fourier Transform with JavaHello,
I'm searching an effective Java library which offers Fourier Transform
methods.
Has someone used a library like this please ?
Thanks
CABA
- 14
- Problem invoking servletHello.
I'm trying to invoke a servlet. I get the following error:
javax.servlet.ServletException:
[HTTP:101250][ServletContext(id=371807,name=BibleApp,context-path=/BibleApp)
]: Servlet class /com/brainysoftware/burnaby/ControllerServlet for servlet
ControllerServlet could not be loaded because a class on which it depends
was not found in the classpath
C:\bea\user_projects\infologic1\applications\BibleApp;C:\bea\user_projects\i
nfologic1\applications\BibleApp\WEB-INF\classes.
java.lang.NoClassDefFoundError:
/com/brainysoftware/burnaby/ControllerServlet (wrong name:
ControllerServlet).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet
----------
web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>simple</servlet-name>
<jsp-file>simplePage.jsp</jsp-file>
</servlet>
<servlet>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>com.brainysoftware.burnaby.ControllerServlet</servlet-class>
<!-- Define initial parameters that will be loaded into
the ServletContext object in the controller servlet -->
<init-param>
<param-name>base</param-name>
<param-value>http://localhost:7001/BibleApp/ControllerServlet</param-value>
</init-param>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>weblogic.jdbc.mssqlserver4.Driver</param-value>
</init-param>
<init-param>
<param-name>imageUrl</param-name>
<param-value>http://localhost:7001/BibleApp/images/</param-value>
</init-param>
<init-param>
<param-name>dbUrl</param-name>
<param-value>jdbc:weblogic:mssqlserver4:users@COMPAQSERVER</param-value>
</init-param>
<init-param>
<param-name>dbUserName</param-name>
<param-value>dinesh</param-value>
</init-param>
<init-param>
<param-name>dbPassword</param-name>
<param-value>werty69</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>test</servlet-name>
<jsp-file>menu_1.jsp</jsp-file>
</servlet>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ShowEmployees</servlet-name>
<servlet-class>ShowEmployees</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/helloservlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>simple</servlet-name>
<url-pattern>/simple</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ShowEmployees</servlet-name>
<url-pattern>/ShowEmployees</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ControllerServlet</servlet-name>
<url-pattern>/controlIt</url-pattern>
</servlet-mapping>
</web-app>
--------------
ControllerServlet.class
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.brainysoftware.burnaby.DbBean;
public class ControllerServlet extends HttpServlet {
/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {
System.out.println("initializing controller servlet.");
ServletContext context = config.getServletContext();
context.setAttribute("base", config.getInitParameter("base"));
context.setAttribute("imageUrl", config.getInitParameter("imageUrl"));
// instantiating the DbBean
DbBean dbBean = new DbBean();
// initialize the DbBean's fields
dbBean.setDbUrl(config.getInitParameter("dbUrl"));
dbBean.setDbUserName(config.getInitParameter("dbUserName"));
dbBean.setDbPassword(config.getInitParameter("dbPassword"));
// put the bean in the servlet context
// the bean will be accessed from JSP pages
context.setAttribute("dbBean", dbBean);
try {
// loading the database JDBC driver
Class.forName(config.getInitParameter("jdbcDriver"));
}
catch (ClassNotFoundException e) {
System.out.println(e.toString());
}
super.init(config);
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**Process the HTTP Post request*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String base = "/jsp/";
String url = base + "Default.jsp";
String action = request.getParameter("action");
if (action!=null) {
if (action.equals("search"))
url = base + "SearchResults.jsp";
else if (action.equals("browseCatalog"))
url = base + "BrowseCatalog.jsp";
else if (action.equals("productDetails"))
url = base + "ProductDetails.jsp";
else if (action.equals("productDetails"))
url = base + "ProductDetails.jsp";
else if (action.equals("addShoppingItem") ||
action.equals("updateShoppingItem") ||
action.equals("deleteShoppingItem") ||
action.equals("displayShoppingCart"))
url = base + "ShoppingCart.jsp";
else if (action.equals("checkOut"))
url = base + "CheckOut.jsp";
else if (action.equals("order"))
url = base + "Order.jsp";
}
RequestDispatcher requestDispatcher =
getServletContext().getRequestDispatcher(url);
requestDispatcher.forward(request, response);
}
}
- 15
- How to get files files which were last usedHi,
is it possible to determine the files which were last used from
different applications (e.g. "readme.txt was used in the last 2 hours")
on MAC with Java by default System calls?
Or is this only possible by writing a sort of "trigger" application?
Thanks,
Peter Vermeer
|
|
|