|
It may not be that straight-forward if your project is using reflection. Suppose you do something like:
Class myClass = Class.forName("com.mycompany.stuff.MyThing");
If you remove the com.mycompany.stuff package from the project, this will still compile with no errors. But when it runs it will collapse in a smoking heap. (If you are using JUnit properly, that should catch it but even so, it's not a real solution.)
This could be a problem if you are using Spring, for example, which uses reflection to instantiate beans.
Or there may be files that need to be in your project (e.g. log4j.properties) that are not referenced directly by your own code, but are required for some third party library you are using. Yes, you can set up the log4j.properties file (or log4j.xml if you prefer) at deployment time but most projects I've seen include it in the build for convenience. Hibernate config files are another example that springs to mind.
I'm not sure that Java has the same concept of "referenced files" that .NET does. An awful lot is just picked up off the classpath at runtime. That makes it quite a bit harder to figure out which files are really "unreferenced".
|
|
|
|
|
You're right, of course. Once reflection rears its ugly (but occasionally beautiful ) head all bets are off, at least in terms of knowing where your code came from.
I don't think that things picked up from the classpath are a big issue here (but of course one'll pop up to make a liar of me!)
Have a 5!
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
What Torsten mentioned should be good enough to get me through most of the ejb stuff, I think. Maybe once I'm a little more comfortable with the app (and J2EE in general) I might go a little deeper into cleaning that part up the way you mentioned Peter. I appreciate it though.
My other problem is in the web section of the J2EE app, let me know if this is veering towards another forum now.
There are a lot of complete files that are not used at all(jsp, js, css, html, xml, etc.) by my application. Many of them are from third party things added in (grid controls, calendar controls, etc), you know there are documentation folders, example folders and then just files that are for different skins and who knows what else. There are also multiple jsp pages that I believe have been replaced by other jsp pages, but the originals haven't been removed. I want to make sure I don't mistakenly remove a needed one though.
I'll apologize now because I've tried looking around and am just not familiar enough with J2EE and Eclipse to know if there is a simple solution for this. Thanks.
"The computer industry is the only industry that is more fashion-driven than women's fashion. Maybe I'm an idiot, but I have no idea what anyone is talking about. What is it? It's complete gibberish. It's insane. When is this idiocy going to stop?" -- Oracle CEO Larry Ellison
|
|
|
|
|
My best wishes go with you. This looks like another example of
inherited project == can of worms and we all know that once you open a can of worms, you're going to need a larger can...
Did a quick google for the quote, but couldn't find it.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
That is part of what I'm after. Thank you for that!
"The computer industry is the only industry that is more fashion-driven than women's fashion. Maybe I'm an idiot, but I have no idea what anyone is talking about. What is it? It's complete gibberish. It's insane. When is this idiocy going to stop?" -- Oracle CEO Larry Ellison
|
|
|
|
|
I need to include the web cam image in gui through applet.I finished capture the image in applet.It works perfectly.But when I include the applet into the gui,applet is crashed.
The crash report file is appeared.The error is java.lang.securityException.Please help me.
|
|
|
|
|
1. Go and look at Google for possible causes of SecurityException[^].
2. Look at your code and check what you are doing when the exception occurs.
3. If you are not catch ing the exception then do so.
The best things in life are not things.
|
|
|
|
|
public static void IzbrisZivali(ArrayList<Zivali>Seznam) throws ConcurrentModificationException
, IOException
{
BufferedReader vhod=new BufferedReader(new InputStreamReader(System.in)) ;
{
System.out.println("Vnesi točno ime živali, ki bi jo radi izbrisali: ");
String IzbrisZivali=vhod.readLine();
int v=0;
for(Zivali Element: Seznam)
if(IzbrisZivali.equals(Element.getIme()))
{
Seznam.remove(Element);
System.out.println("Žival " + IzbrisZivali + " je bila izbrisana");
v++;
}
if(v==0)
{
System.out.println();
System.out.println("Na seznamu ni živali z imenom " + IzbrisZivali);
System.out.println();
}
}
}
How can i fix that? What should be changed. Please solve me this problem as im sitting here and staring at my computer for 2 hours! Please!
The problem is ConcurrentModificationException
Regards,
Matjaž
|
|
|
|
|
You can't iterate this way over your list (Seznam) while removing elements at the same time. Instead you should you use an iterator and call remove on the iterator:
Iterator iter = Seznam.iterator();
while (Seznam.hasNext()) {
Zivali element = iter.next();
...
...
if (.....) {
iter.remove();
}
}
BTW: this is a forum not a chat, so you can't request "URGENT HELP!". Your question is not more urgent than other questions. If it is really urgent, then you should pay somebody to fix the problem for you. And please, use a better title next time you ask a question, everybody knows that if you ask a question, you want some help... Please, read the posting guidelines at the top of this message board.
|
|
|
|
|
This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. For example, it is not generally permissible for one thread to modify a Collection while another thread is iterating over it.
That's what the documentation says. You might figure out what happens when you make your function non-static. And please debug your code.
- do not name variables with capital letter ("Element") That's really dangerous and can have side effects as Object names are started with a capital letter (e.g."System", "BufferedReader").
- always use English comments.
regards
Torsten
I never finish anyth...
|
|
|
|
|
I want to identify an image in an application window.
To be more specific, I want to know how i can identify if the image exists
and if it is at the right location in the window.
|
|
|
|
|
Where "identify" means what exactly?
If you mean you want to figure out that a picture, for example, has a dog in it then you need to research pattern matching algorithms (or maybe "image pattern" but something like that.)
The algorithms are independent of language.
|
|
|
|
|
I have PictureDrawable that I wish to save as an image (JPEG/PNG) but I can't seem to find any information how to go about this.
I tried this but it does not seem to work
PictureDrawable myDrawable = GetPictureDrawable();
Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
myDrawable.draw(new Canvas(bitmap));
bitmap.compress(CompressFormat.JPEG, 100, new FileOutputStream("/MyLocation/MyImage.jpg"));
What am I doing wrongly?
www.belfox.net
...Simplicity at its best
|
|
|
|
|
|
1.
public static void savePic(Bitmap bitmap, String saveFilePath) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(saveFilePath));
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
}
2.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> add in the file "AndroidManifest.xml"
3.
Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(), R.drawable.g7);
try {
savePic(bitmap, "/mnt/sdcard/test.jpg");
} catch (Exception e) {
e.printStackTrace();
}
modified on Friday, June 3, 2011 1:22 AM
|
|
|
|
|
Your answer shows how to save a Bitmap to a the SDCard. However, my question was how to save a PictureDrawable to the memory card.
I needed to know how to convert the PictureDrawable to a Bitmap.
www.belfox.net
...Simplicity at its best
|
|
|
|
|
private static Bitmap pictureDrawable2Bitmap(PictureDrawable pictureDrawable){
Bitmap bitmap=Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(),pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas=new Canvas(bitmap);
canvas.drawPicture(pictureDrawable.getPicture());
return bitmap;
}
|
|
|
|
|
I need to embed an excel sheet into a java GUI.
Read online that it can be done using "owc".
Can someone please tell me how I can use "owc" in
my java code.
|
|
|
|
|
|
You need a Java-COM bridge tool which will wrap your Excel COM object in a Java proxy. Many moons ago we used a tool from J-Integra to run a Word mail merge from Java but someone may have produced an open source version which will work: JACOB
Disclaimer: We ran the Word merge from command line, not integrated into a Swing app. J-Integra appears to support Swing integrations, but it's a very old page and does the integration through a JBuilder (Jurassic version 3.5!) GUI tool.
|
|
|
|
|
Hi,
did you manage to achieve your goals? I'm looking into the same topic but do not find anything promising.
regards
|
|
|
|
|
Hi.
I'm new at Java... also helping my girlfriend to do her work (sigh:P)....
Anyway... im stuck a bit at adding text to an existing file...
Is there any simple way editing this?
try <br />
{<br />
PrintWriter inFile= new PrintWriter(new FileWriter("Text.txt"));<br />
PrintWriter inFile1= new PrintWriter(new FileWriter("Text1.txt"));<br />
<br />
<br />
for (SOMETHING Element:Something)<br />
{<br />
izhod.println(Element.inFile());<br />
izhod1.println(Element.inFile1());<br />
<br />
<br />
}<br />
inFile.close();<br />
inFile1.close();<br />
}<br />
catch(Exception e)<br />
{<br />
System.out.println("Error.");<br />
}
Or must i rewrite everything and use buffered reader? If thats so, can you show me what to do
Thanks in advance!
Regards,
Matjaž
|
|
|
|
|
japp, try to use BufferedReder and BufferedWriter - if allowed by your teacher
There are great Tutorials at oracle.com:Big Index @ oracle.com[^]
please bookmarks that one and refer to it when having trouble. They are really well made.
For your current situation I'd suggest File I/O operations[^]
regards
Torsten
I never finish anyth...
|
|
|
|
|
Ha ha! You are good! I come from China, I love programming, a student, my English is good bad, I came here to learn more technical and handed foreign friends, thank you! Is there any way I can chat with you, I want to speak English, MSN it? Or e-mail?
Hi ! My name lanmingle , i from china .
|
|
|
|
|
Hi,
I have a class "worldstore" that is derived from "Service" class and implements interface "ILamp".
I have a method called "getState" in ILamp interface which returns a "boolean" and another method is available with the same name in "Service" base class which returns an "int".
While implementing the methods of the interface in "worldstore" class, I get an error when implementing "getState" from ILamp. Whereby, eclipse detects it to belonging to the base "Service" class rather than that of the ILamp interface, and therefore asks me to change the return type to boolean.
All i want is to implement the "getState" method from the interface.
Any solutions please... I am using java 1.6
Thanks.
|
|
|
|