0

I have this pieace of code:

    Calendar ca=Calendar.getInstance();
    FileWriter fw = new FileWriter("Locations_Elapsed time iterations.txt", true);
    PrintWriter pw = new PrintWriter(fw);              
    ca.setTime(new Date());                      
    a++;
    pw.write("user " + a + " " + ca.get(Calendar.MILLISECOND));
    pw.println();
    pw.close();

It works fine when I run it with netbeans (ofcourse). I want to execute it on a server away from my machine which works with Linux, so I make a jar file to do this.

The problem is that it is not writing anything. Any ideas?

Thanks!

Iraklis
  • 208
  • 1
  • 5
  • 16

2 Answers2

1

I can't comment yet: can you give a little more detail about what happens when you launch the jar? How do you launch it? Where is the file you are calling stored?
At first glance I would think that you don't have a exception handling and thus you cannot see that the file hasn't been found or something on the like.
By the way, I suggest you (for testing purposes) to use Files.write

Community
  • 1
  • 1
Vale
  • 1,104
  • 1
  • 10
  • 29
0

It might be that the user who is running the program does not have write permission in the directory in which the file Locations_Elapsed time iterations.txt is to be created.

Sanjeev Saha
  • 2,632
  • 1
  • 12
  • 19