|
Hello Nagy
First,Thx for ur Reply.
My jar file is also in same source folder. And I am running it by double click the jar file that opens my application.After that i am loading file on some button click.
And Is there any difference If I use front Or backSlash while giving the relative path?
Thanks Once Again for ur Precious time to answer my question.
Regards
Yogesh
|
|
|
|
|
Hi guys
Actually This is an applet where I am loading a file.Now,when I run from some hard drive location with parameter '.\test1\readfile then Its working with this relative path and in firefox browser not in IE.
Now When I Load the same in localHost and then tried then it is not loading even in firefox with relative path.
Now,two question.why its not loading in IE with relative path?
Why its not loading when I run in LocalHost?
Any ideas Please?
Thanks & Regards
Yogesh
|
|
|
|
|
Hello Guys
The main problem is that i want to load resources through jar applet from System or when it is host?
ANy Ideas Now?
Regards
Yogesh
|
|
|
|
|
The simple answer to your question is "don't". Using relative paths can never be relied upon as your application has no control over the setting of the current directory. Always use absolute path specifications or use an environment variable as the root to the relative path.
It's time for a new signature.
|
|
|
|
|
Hello Richard Sir
But how can I use everytime absolute path when I have to host the site.then while loading file I need to specify some system independent path ?
Any Ideas?
Regards
Yogesh
|
|
|
|
|
Hello Guys
Do u know how can i set system properties of jvm in which i can specify the path.We can set it thru Project properties then under run in vm options
With -D and after that what we have to write?
Any Ideas?
Regards
Yogesh
|
|
|
|
|
java -D"property=C:/dir/subdir" class
Your program can now find the value of 'property' through the java.util.Properties class.
It's time for a new signature.
|
|
|
|
|
Take a look at
System.getProperties().list(System.out);
this will give you a list of all the default system properties, so you can figure out where your file should be stored so you can address it with a relative path.
It's time for a new signature.
|
|
|
|
|
Hello Sir
I setted System properties of jvm with -DservPath=c:\test
And when I tried to get property,it is returning null. I tried like this
Properties prop = new Properties();
String path = prop.getproperty("servPath");
And like this too
String Path = System.getProperty("servPath");
I want to tell u that this file is not in jar file,this is out of jar file that i want to load.
In both cases,it is returning null.
Its looking like i am very near.
What happening Now sir?
Regards
Yogesh
|
|
|
|
|
yogeshs wrote:
Properties prop = new Properties();
That can never work as you are creating a new Properties object which will be empty. The value will be inserted into the System.Properties and you should be able to obtain the value by
String path = System.getProperty("servPath");
which works in my test. You may want to check you are making your java call correctly like this
java -DservPath=c:\test [jar or class name ]
It's time for a new signature.
|
|
|
|
|
Hello sir
I dont know whats happening.When i print system properties then its showing mine property in list but when I am getting thru System.getProperty("servpath") giving null.
And I am setting -DservPath=c:\test\test.jar in Netbeans Project properties dialog under Run section in VM options.
I appreciate for ur time.
Regards
Yogesh
|
|
|
|
|
I use Eclipse rather than NetBeans and it works when running in the Eclipse IDE and also from the command line. However in your post above:
System.getProperty("servpath")
-DservPath=c:\test\test.jar
Do you notice the difference in the spelling between "servpath" (lower case 'p') and "servPath" (upper case 'P').
It's time for a new signature.
|
|
|
|
|
Yeah,I am aware about spelling of servpath.That is by mistake here in posting only not in my code.
Thanks & Regards
Yogesh
|
|
|
|
|
yogeshs wrote: That is by mistake here in posting only not in my code.
That's why we have Copy/Cut & Paste!
It's time for a new signature.
|
|
|
|
|
Hello Sir
I found one thing that when I enable Web Start configuration In NetBeans then it is not showing servPath but when I uncheck Enable Web Start(means default configuration) then it is showing the value of servpath.
What could be the reason?am I missing anything else?
Thanks & Regards
Yogesh
modified on Thursday, July 1, 2010 12:30 AM
|
|
|
|
|
Sorry, I have no experience of NetBeans, so I cannot suggest anything. However you mentioned Web Start, so I suspect this is not a standard Java app and perhaps the properties in Web Start are handled in a different manner.
It's time for a new signature.
|
|
|
|
|
ok,Anyway,thanks for your precious Time.
Regards
Yogesh
|
|
|
|
|
Hello Sir
Actually In Windows I am using this code to find the path of running jar file:
File ff =new File(classname.class.getProtectionDomain().getCodeSource().getLocation().getPath());
String jarFilePath = ff.toString();
Now when we hosted the site on Linux server then it is not showing the full path.Its showing only the name of jar file.
Is there way to get full path of jar that is on Linux server.
Thanks & Regards
Yogesh
|
|
|
|
|
Yogesh,
If you are talking about reading a resource from relative path with respect to current class, consider using this snippet:-
1) getClass().getResource("url") which will give you URL instance which can be used to read a resource
2) getClass().getResourceAsStream("file or any other resource") which returns an InputStream
anand in dnr
|
|
|
|
|
Hello Friends
I am creating a Executable jar file using NetBeans.In Project properties under Run I was setting -Xms1024m -Xmx1024m and it was loading file whenever i click on executable jar file.And virtual memory for c drive also setted in paging section from 1024 to 1024.
Now,I want to load a big file and this executable jar is not working.So,I increase virtual memry first to 2048 to 2048 and then in my project properties I setted to -Xms2048m -Xmx2048m but it is not loading.Do I need to make any other changes to load any big file?
Any Ideas guys.
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
First thing to do is verify what the problem is, not trying to make assumptions. Did you get an exception ? If yes, copy the stack trace here so that we can have a look. If you don't have enough memory, you should get a memory exception.
|
|
|
|
|
Hello Sir
It is giving error:
Exception in Thread :java.lang.outofmemoryerror :java heap space.
i setted virtal memory to 4096m
And in Netbeans isetted to -Xms2048m -Xmx2048m
Thanks For ur Reply
Regards
Yogesh
|
|
|
|
|
The first thing to be aware of is that if you are running under Windows, you won't be able to use much more than 1Gb of memory for your Java heap space (certainly true for 32 bit, may be different for 64 bit Windows). The reason is that the Sun JVM requires heap memory to be allocated contiguously (in other words, in one big continuous block of memory). Because of the way Windows loads DLLs into memory, Windows can't normally allocate contiguous blocks of memory bigger than roughly 1 gig (off the top of my head the figure that springs to mind is 1.2Gb but that may be wrong). You can do things like shuffling DLLs around but even then you don't get a lot more and it's probably not worth the effort. Things may be different with 64 bit Windows, I don't know because I've not worked with it very much yet. Things may also be different with other JVMs (I used to use JRockit 5 years ago with WebLogic and that was the same at the time, but I believe that now it no longer requires contiguous memory and so does not suffer from this problem.)
But I would turn this question around: what are you doing that is blowing so much memory so quickly? It sounds to me as if there is something amiss here and instead of throwing more memory at the problem, maybe you could reconsider your design?
|
|
|
|
|
Hello David Sir
Actually the design demands for this type of memory requirement.I have to load a file dynamically with initialisation whose size is around 3.5MB.
But If I load file around 1mb then its working.So to load heavy file I increased the heap space to 2048 then it is not running even thru netBeans,error comes like
Could not create the Java virtual machine.
Error occurred during initialization of VM
Could not reserve enough space for object heap
Java Result: 1
Thanks For ur reply.
Any Ideas?
Regards
Yogesh
|
|
|
|
|
Any Other Ideas Guys??????
I think i made it very confusing.let me Explain u in better way.
The Simple thing is that When I set Heap Space -Xms1024m -Xmx1024 then its working fine. But As I increased to -Xms2048m -Xmx2048 then when I try to run thru NetBeans even It gives me the Error:
run:
Error occurred during initialization of VM
Could not create the Java virtual machine.
Could not reserve enough space for object heap
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
What do i Need to change to increase Heap Space.
And If I run thru batch file in which I specify
java -Xms512m -Xmx1024m -jar sample.jar
Thanks & Regards
Yogesh
|
|
|
|