• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue when adding a java program to windows startup using .bat file  RSS feed

 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I've added a small program that reads from a .txt file to the windows 8 startup folder using a .bat file
The problem I have Is I've used relative paths for text files In the program and It doesn't work unless I change them to absolute paths.
The .bat file Is basically . Is there something (most likely yes!) I'm missing here ?







 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a problem with using the absolute path here? It seems to me that the problem you are trying to solve is to get the program to run on startup, and you seem to have solved that.
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:is there a problem with using the absolute path here? . . .
Do you mean something like this in the .bat file?
java "C:\Users\Campbell\Java Programs\foo.bar.baz.MyProgram"
You may need quotes round the instruction because of the space after Java.

Avoid the -cp instruction unless you need it when you execute the program. It might be better to wrap the entire application in an executable JAR file.
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikolas Nikolaou wrote: The problem I have Is I've used relative paths for text files In the program and It doesn't work unless I change them to absolute paths.


Then the solution is to precede that single line by a line which sets the current working directory to whatever directory your paths are relative to. You'd use the "cd" command for that.
 
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The CD command (facepalm!) oh yeah !!
Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!