My programs objective is to mkdir and ope dir.

if I ever get it jarred up I would like to run it from a jump drive.

[code]

public static final String USERHOMEDIR = System.getProperty("user.home", ".");

[/code]

clearly this code will not be valid any more.
Could this USERHOMEDIR be replaced correctly each time the jump drive is moved from one client to the
next?

again the main objective of the program would be to create dir's and place doc in a a file system on the
jump drive and maintain access to those dir no matter where I use the jump drive.

are there other unforseen technical hurdles to jump over?
thanks;
5:10 AM 2/25/2013

Recommended Answers

All 13 Replies

Assuming you have done nothing bizarre with class loaders, this code snippet, running in an instance of a class loaded from the jar, gives you a File reference to the jar file...

File jarFile = new File(this.getClass().getProtectionDomain().getCodeSource() .getLocation().toURI());

From that you can easily get a reference to any other dir on the same logical drive as the jar - is that what you are looking for?

yes it is thanks much.
seeing as I have to learn a lot to jar it up first this reference will be saved and used when the time comes.
I am sure there will be other obsticals to over come but this looks cool thanks

The program I am asking about is now running as a standalone app from my jump drive. I am trying to relocate where the dir are being created and accessed. It is still using files on my computer I am still working on
changing code per your last
post thanks.

When I came to this (not mine) computer and tried to run my app (on my jump drive) it said....

E:\guide.jar is not a valid Win32 application.

Now I am in deep water. What am I trying to do? Can I get an app I created to run on any computer. It is soon to be running totally from my jump drive.
thanks again.

How did you try to run it? Double-click? Command line? Does that computer have a Java runtime installed?

Excellent questions. I do not think so. It is a public computer. Is there a risk to them to install it. I would think it would be ok. I double clicked it. Maybe I will try to install the
Virtual machine if it will let me. Do you think it should run from my jump drive if there
Is a java runtime?
Thanks again.

It will no let me download the java runtime.

If its someone else's computer then you may have all kinds of objections to installing Java on it.
If you have enough room you could put a JRE on the thumb drive, and use a tiny batch file on the drive to invoke javaw.exe from that drive to run your jar (use relative paths in the .bat so it doesn't depend on the drive letter). There's quite a lot of stuff to Google on the web if you need more detailed instructions.

nice.
the .bat file? I will try to download the JRE to the thumb drive. I will search the IE but I do not know
much about making a batch file. Is there some relative link for what I am trying to do? or some good key words to google?
thanks

I downloaded the JRE to my thumb drive. Do I need to install something? or is that why I need to learn how to write a .bat file?
thanks

This web page has details on running the JRE from a DVD or thumb drive (first answer)

Thanks for the help. I will have to return to this computer next chance I get. Maybe I will learn
someting form the links by then.
Thanks again.

The app on the thumb does open on my test computer. Can you throw out some key words that will hone me in on some
batch file writing?

thanks

Hello again.
I have a guideJRE.bat with
jre\bin\java.exe -jar guide.jar

Do I need to start the main.class. If so it is in the guide.zip in a bin dir and in the place that my
build.xml put it via the manifest build.classes.model.main.class.confused here.

I followed some instructions from a related post :

Indeed you can simply put a JRE into a directory of the DVD.Then you start the application with a .bat file that runs a command such as : jre\bin\java.exe -jar Main.jar (If your jar and the jre folder are in the same directory)Be careful about one thing : you can't know in advance what the DVD's drive letter will be, so in your .bat file you must give relative paths to the JRE and to your jar (or starting class).

my guideJRE.bat is a sibbling to my guide.jar and the bin that I extracted form the JRE that is on my
thumb drive as well.

I would like to run my app entirly from my thumb and the computers ask if I have an admin password to
change the computer. the computer did not know what a .jar file was so I instructed it to open with the
thumb drive jre\bin\java

result. the computer command screen blinks and that is it.

On a similar topic. I noticed an *.inf file.

is there a way to eventually plug the thumb drive in and have it open my app?

this code was in the autorun.inf

[Autorun] Icon=PortableApps\PortableApps.com\App\Graphics\usb.ico Label=PortableApps.com

is this what is opening my drive automatically now?

thanks talk to you in a few days.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.