Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
All,
Is there a Java or ImageJ class/method that will return the current working directory that a class file resides? I have compiled a separate copy of ImageJ.java, but can't seem to find out where the IDE I am using puts the class file. David Webster -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi,
Does Johannes' solution do it for you? https://list.nih.gov/cgi-bin/wa.exe?A2=ind0707&L=IMAGEJ&D=0&1=IMAGEJ&9=A&I=-3&J=on&d=No+Match%3BMatch%3BMatches&z=4&P=65839 TinyURL = http://tinyurl.com/73cose6 Cheers, Ben On Jun 30, 2012, at 3:51 PM, David Webster wrote: > All, > > Is there a Java or ImageJ class/method that will return the current working > directory that a class file resides? I have compiled a separate copy of > ImageJ.java, but can't seem to find out where the IDE I am using puts the > class file. > > David Webster > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Ben,
I don't know if this would help as I don't recall seeing .config files in the same dir as my class file (e.g. the plugins folder). In any case, I was compiling imagej.java and didn't realize that when you compile a package, a folder is created. Thanx - David Webster On Sat, Jun 30, 2012 at 3:35 PM, Ben Tupper <[hidden email]> wrote: > Hi, > > Does Johannes' solution do it for you? > > > https://list.nih.gov/cgi-bin/wa.exe?A2=ind0707&L=IMAGEJ&D=0&1=IMAGEJ&9=A&I=-3&J=on&d=No+Match%3BMatch%3BMatches&z=4&P=65839 > > TinyURL = http://tinyurl.com/73cose6 > > Cheers, > Ben > > On Jun 30, 2012, at 3:51 PM, David Webster wrote: > > > All, > > > > Is there a Java or ImageJ class/method that will return the current > working > > directory that a class file resides? I have compiled a separate copy of > > ImageJ.java, but can't seem to find out where the IDE I am using puts the > > class file. > > > > David Webster > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > ... [show rest of quote] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi David,
On Sat, 30 Jun 2012, David Webster wrote: > I don't know if this would help as I don't recall seeing .config files in > the same dir as my class file (e.g. the plugins folder). You can call getResource() with the .class file itself as parameter. Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
I know I'm being terribly clueless, but what class does getResources()
belong to? David On Sun, Jul 1, 2012 at 1:20 PM, Johannes Schindelin < [hidden email]> wrote: > Hi David, > > On Sat, 30 Jun 2012, David Webster wrote: > > > I don't know if this would help as I don't recall seeing .config files in > > the same dir as my class file (e.g. the plugins folder). > > You can call getResource() with the .class file itself as parameter. > > Ciao, > Johannes > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi David,
On Sun, 1 Jul 2012, David Webster wrote: > On Sun, Jul 1, 2012 at 1:20 PM, Johannes Schindelin < > [hidden email]> wrote: > > > On Sat, 30 Jun 2012, David Webster wrote: > > > > > I don't know if this would help as I don't recall seeing .config > > > files in the same dir as my class file (e.g. the plugins folder). > > > > You can call getResource() with the .class file itself as parameter. > > I know I'm being terribly clueless, but what class does getResources() > belong to? Example: let's assume you have a class called MyClass and its .class file is outside a .jar file. Then String path = MyClass.class.getResource("MyClass.class").getPath(); File directory = new File(path).getParentFile(); will give you the directory in which MyClass resides, as a java.io.File object. If the class resides inside a .jar file and you want the directory in which the .jar file lives, it gets slightly more complicated: String path = MyClass.class.getResource("MyClass.class").getPath(); if (path.startsWith("jar:")) path = path.subtring(4); if (path.startsWith("file:")) path = path.subtring(5); int bang = path.indexOf("!/"); if (bang > 0) path = path.substring(0, bang); directory = new File(path).getParentFile(); Ciao, Johannes -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
That works!
On Mon, Jul 2, 2012 at 7:09 AM, Johannes Schindelin < [hidden email]> wrote: > Hi David, > > On Sun, 1 Jul 2012, David Webster wrote: > > > On Sun, Jul 1, 2012 at 1:20 PM, Johannes Schindelin < > > [hidden email]> wrote: > > > > > On Sat, 30 Jun 2012, David Webster wrote: > > > > > > > I don't know if this would help as I don't recall seeing .config > > > > files in the same dir as my class file (e.g. the plugins folder). > > > > > > You can call getResource() with the .class file itself as parameter. > > > > I know I'm being terribly clueless, but what class does getResources() > > belong to? > > Example: let's assume you have a class called MyClass and its .class file > is outside a .jar file. Then > > String path = MyClass.class.getResource("MyClass.class").getPath(); > File directory = new File(path).getParentFile(); > > will give you the directory in which MyClass resides, as a java.io.File > object. If the class resides inside a .jar file and you want the directory > in which the .jar file lives, it gets slightly more complicated: > > String path = MyClass.class.getResource("MyClass.class").getPath(); > if (path.startsWith("jar:")) path = path.subtring(4); > if (path.startsWith("file:")) path = path.subtring(5); > int bang = path.indexOf("!/"); > if (bang > 0) path = path.substring(0, bang); > directory = new File(path).getParentFile(); > > Ciao, > Johannes > ... [show rest of quote] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
In reply to this post by David Webster
Java training by SevenMentor Institute in Pune stands out as a premier program for mastering Java programming. Renowned for its industry-focused curriculum, the institute provides in-depth training on core and advanced Java concepts, ensuring learners gain hands-on expertise in object-oriented programming, data structures, web development, and frameworks like Spring and Hibernate. The trainers are experienced professionals who bring real-world insights into the classroom, making the sessions engaging and practical.
SevenMentor emphasizes a project-based approach, enabling students to apply their knowledge to real-time scenarios, thereby building confidence and skills required by the industry. With state-of-the-art facilities and flexible training schedules, including online and classroom options, the institute caters to students and working professionals alike. Their excellent placement support, coupled with resume-building and interview preparation sessions, helps learners secure rewarding job opportunities. For anyone looking to excel in Java, SevenMentor in Pune offers a comprehensive and enriching learning experience. Visit us: Java training classes in Pune Java training course in Pune Java course in Pune |
Free forum by Nabble | Disable Popup Ads | Edit this page |