|
Hello Friends
One of my java application is using around 70MB when I checked through Task Manager.I tried to monitor through java profiler then there it is showing 4MB Heap memory and 64Mb non Heap Memory.
And In actual application is not taking this much memory So i want to reduce this memroy consumption.
Any Ideas Guys.
Thanks & Regards
Yogesh
|
|
|
|
|
This isn't a particulary large amount of memory, but then it depends on the app. If it's HelloWorld then it's way too much, if it's a word clone then you're doing well.
Seriously, check that you are not duplicating objects, two references to the same object uses less memory than two instances. Don't hold objects once they are no longer needed. Do you have a collection of objects that are rarely used, maybe you can optimise there by only holding in memory what is used.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Thanks A Lot Mr.Nagy For ur valuable time to my answer.
Regards
Yogesh
|
|
|
|
|
Hello,
I need to determine that whether given file is a class file or not? Perhaps I may change the extension to .exe/.xml or some other . I need to dtermine that given file if a class file will be parsed differently and if it would be some other, it'll be parsed in that manner.
How can we determine by reading class file format if, How can we read programatically class file format?
Regards
Usman
|
|
|
|
|
What are you trying to do exactly ? What is the reason why you want to do something like that ?
Are you talking about .java files ?
glitteringsound wrote: How can we read programatically class file format?
A class loader does that for you.
|
|
|
|
|
I need to just read and parse programatically Java class file header. So that I can determine weather its class file or not. I need that one to determine in my case. Possibly not in usual cases but just in my case.
|
|
|
|
|
glitteringsound wrote: I need to just read and parse programatically Java class file header.
What do you mean by header ?
But you still didn't answer my question, you merely repeated your first post: what is the reason why you want to do something like that ? Your request seems really akward, so it would help a lot to understand your question if you provide the context.
|
|
|
|
|
Respectfully
Sir,
I am working on app (kind of framework) which parse and extract function signatures and populate them on GUI. This needs to be first determine weather given file is a class file, Win32 File or COM Exe/DLL, Js or HTML file.(As in my case these all files can be made as input to framework by the user). This needs to parse given file format (probably headers)first to determine whether given file is within above mentioned context or not.?
Regards
Usman
|
|
|
|
|
glitteringsound wrote: I am working on app (kind of framework) which parse and extract function signatures and populate them on GUI.
Are the classes loaded in your application ? If yes, it would be much easier to use reflection to extract the information about the classes and methods (you won't need to do the parsing yourself, which is not an easy job).
glitteringsound wrote: This needs to parse given file format (probably headers)first to determine whether given file is within above mentioned context or not.?
A class file is just a text file, so there's no "header" (like for instance in a binary file) containing info about the file. You could check the extension though (it should be .java).
|
|
|
|
|
|
A simple Google search found this[^] document containing all the detail you need?
It's time for a new signature.
|
|
|
|
|
Hello Friends
I want to install java on client machine if it is not installed through applet tag.I did through object tag but same I want to do through Applet tag.
Here is Object Tag:
<object id="viewer" classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
codebase="http://java.sun.com/update/1.6.0/jinstall-6-fcs-windows-i586.cab"
width=360
height=557 >
<param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher" >
<param name="archive" value="http://download.java.net/media/applet-launcher/applet-launcher.jar,
This code automatically installs java but I want to do same through applet tag.I made some changes but it is not asking user to install.here is applet tag and please let me know wat do i need to change to install java?
Applet tag:
<applet
code="print_canvas3d.PrintCanvas3D "
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-win.cab"
width=360
height=557
archive="http://www.styku.com/wer.jar,
http://download.java.net/media/applet-launcher/applet-launcher.jar,
And one more prob is If I provide class name directly in code=pkg.classname then it is giving me right Id but If i use JNLPAppletLauncher at the same place then I am getting the Id of jnlpLaunched that I dont want ,I want the id of mine main class.How can i get?
Thanks & Regards
Yogesh
|
|
|
|
|
 Hi Guys
I found Something and now I need ur help.Here is the code below,After using this code,It asks If java is uninstall but after that it is not loading my jar file,is it some path issue. Or if java is already installed on sytem then it loadds my jar file.
<applet
code="org.jdesktop.applet.util.JNLPAppletLauncher "
codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
width=360
height=557
archive="http://www.sample.com/view/view.jar,
http://download.java.net/media/applet-launcher/applet-launcher.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dcore.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dutils.jar,
http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
http://download.java.net/media/java3d/webstart/release/vecmath/latest/vecmath.jar"
id="viewer">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="canvas3d.Canvas3D">
<param name="subapplet.displayname" value="My Java 3D Applet">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1" value="http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp">
<param name="progressbar" value="true">
<param name="noddraw.check" value="true">
</applet>
Any Ideas Guys Now.
Regards
Yogesh
|
|
|
|
|
Good, you found solution
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Hello Guys
i am trying to write a file to server with URLConnection.And here is the code below.I created one file at that location and with my code trying to write some thing but nothing is happening.I need some ideas.Or is it some issue with access to server on that file?
Code:
try {
URL url;
URLConnection urlConn;
DataOutputStream dos;
DataInputStream dis;
url = new URL("http://sample.com/test/file.txt");
urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
dos = new DataOutputStream (urlConn.getOutputStream());
String message = "Yahoooooooo";
dos.writeBytes(message);
dos.flush();
dos.close();
dis = new DataInputStream(urlConn.getInputStream());
String s = dis.readLine();
dis.close();
}
catch (MalformedURLException mue) {
addTextField.setText("mue error");
}
catch (IOException ioe) {
addTextField.setText("IO Exception");
}
Any Ideas guys.
Thanks & Regards
Yogesh
|
|
|
|
|
For as far as I know webservers will not allow you to do this, at least not the way you want by opening or creating a file remotely and writing to it.
What you could do is write some servlet or JSP code on the remote server that accepts POST data and writes that to a file. You can then POST any content to that JSP / Servlet and store data that way.
EG:
server A has a servlet called /StoreFile
server B calls http://serverA/StoreFile
with POST data
fileName=file1.txt&data=<yourencodeddata>
|
|
|
|
|
Hello Gerban
THanks for ur reply but I am reading the file from server in same way.Thats why I thought that writing is also possible in the same way.
And i got this solution from net.
Anyway,I will try ur way also but still If u know any other way then please let me know.
Thanks Again for ur replay.
Regards
Yogesh
|
|
|
|
|
Reading should never cause you any issues, as this is the primary reason to have a webserver (get access to remote files).
The real question is why would you want to have unprotected writing to a webserver at all (which you are doing if you open a file on a remote server and just start writing in it). You would create a serious security risk.
If it is at all possible to write directly to a webserver from a remote connection then that will be a security setting on the webserver, and not on the Java side of things. So maybe you should also ask this question on some forums relating to Tomcat / Apache or whatever webserver you are running.
|
|
|
|
|
Thanks For ur Reply.
Yeah,I understand this would be a security risk.So I have to drop this way.
Thanks
Regards
Yogesh
|
|
|
|
|
Hello Friends
I want to add progress bar moving while I am reading a file.
Any Ides Guys?
Thanks & Regards
Yogesh
|
|
|
|
|
The simplest option is simply to start a progress bar running in indeterminate mode (i.e. the bar just bounces back and forwards to show you that something is happening), then load the file, then stop the progress bar when you are finished loading. That way you never need to worry about how big the file is.
The alternative is to get the length of the file before you start (create a File object, and call length()) then track the number of bytes you have read in as a percentage of the total and update the progress bar periodically. Don't update the progress bar too often (e.g. if you have a 2Mb file and you update the progress bar after reading every individual byte, you will be updating the progress bar over 2 million times, which is obviously not a good idea). Make sure you don't load the file on the Swing event handling thread, but make sure that you do update the progress bar on the EDT.
Or, you could use a ProgressMonitor, which is an inbuilt progress dialog that is sometimes useful.
Progress bar tutorial here:
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/progress.html[^]
|
|
|
|
|
Thanks A Lot.Mr David
Regards
Yogesh
|
|
|
|
|
Hello Friends
I am using file object to with URL path as parameter to pass filename to some function.But it is not creating File Object.I tried like this:
String filePath="http://test.com/folder/file.txt
File f = new File(new URL(filePath).toURI());
And like this too
File f = new File(new URL(filePath).getPath());
but it is crashing at this point.
Any Ideas Guys.
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
yogeshs wrote: but it is crashing at this point.
Any Ideas Guys.
Well perhaps if you showed the error that you received we may be able to help work out what is going wrong. However, I am not sure that you are allowed to create files on a client machine in this way.
It's time for a new signature.
|
|
|
|
|
Hello Sir
Actually I am facing some exception when I run and its java.lang.reflect.InvocationTargetException.
May be this one useful for you.I searched for this but didnt found anything.
Thanks & Regards
Yogesh
|
|
|
|