You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

1

Friday, July 19th 2013, 7:41pm

App.Path

I am Using V. 1.5.2
I have installed Jabaco-rev105.jar

I am trying to find the App.Path.
That Function is no longer working.
I want it because I don't want to install the program that I am Making on the user's computer, but I want the program to run and access files from the USB flash drive.

Is there a work around? Perhaps a new method I don't know about?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Friday, July 19th 2013, 8:22pm

Quoted

I am trying to find the App.Path.


Hmmm. it is still there.
And on my System, it works. It is similar to CurDir.

Jabaco Source

1
2
3
4
5
6
7
8
Public Sub Command1_Click()
   MsgBox App.Path  
'   MsgBox CurDir
'   MsgBox TmpDir
'   MsgBox TempDir
'   MsgBox HomeDir
'   MsgBox JavaDir
End Sub


If it still don't work, try the complete name:

Jabaco Source

1
2
3
4
5
6
7
Public Sub Command1_Click()
   MsgBox VB#FileSystem.CurDir
'   MsgBox VB#FileSystem.TmpDir
'   MsgBox VB#FileSystem.TempDir
'   MsgBox VB#FileSystem.HomeDir
'   MsgBox VB#FileSystem.JavaDir
End Sub

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

3

Friday, July 19th 2013, 8:37pm

I use WinXP
On my system the App.Path stopped working when I changed the .Jar to Jabaco-rev105.jar

As you suggested I used
msgbox VB#FileSystem.CurDir


it yeilded this error:

java.lang.Exception: CallByName 'CurDir' failed!
at VBA.Interaction.CallByName(Interaction.java:187)
at VBA.Interaction.CallByName(Interaction.java:185)
at VBA.Interaction.CallByName(Interaction.java:176)
at frmLibrary.Form_Load(frmLibrary.jsrc:474)
at VB.AbstractForm.fireLoaded(AbstractForm.jsrc)
at VB.LoadAdapter.run(LoadAdapter.jsrc)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Any Ideas?

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

4

Friday, July 19th 2013, 9:05pm

In fact if I try to declare it as an object, I can't even get that method from the list.

See Pic Below.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

5

Friday, July 19th 2013, 9:17pm

In fact if I try to declare it as an object, I can't even get that method from the list.

See Pic Below.


Do you really sure, that you are using Jabaco-rev105.jar ?
On my system (XP in VirtualBox) it works and it is there.

If you have the old Jabaco.jar it is in
VBA#FileSystem
in the new Jabaco.jar it is in
VB#FileSystem

Please rename Jabaco.jar to Jabaco.zip and look if there is a directory VB in which is the file FileSystem.class.
Or try to download Jabaco-rev105.jar again:
https://jbaindi.googlecode.com/files/Jabaco-rev105.jar
Possible your copy of it is damaged...

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

6

Friday, July 19th 2013, 9:36pm

Hey there,

I know it is a bit of an overkill but this has proven to be reliable on Win and Mac with the compiled program:

Jabaco Source

1
Debug.Print Replace(Replace(Left(getClass().getProtectionDomain().getCodeSource().getLocation(),InStrRev(getClass().getProtectionDomain().getCodeSource().getLocation(), "/")),IIF(Left(Mid(getClass().getProtectionDomain().getCodeSource().getLocation(),8),1)=":","file:/","file:"),""),"%20"," ")


as long as you are on Windows machines only:

Jabaco Source

1
Debug.Print Mid(getClass().getProtectionDomain().getCodeSource().getLocation(),7)


Dani

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

7

Friday, July 19th 2013, 9:42pm

YES!!!

I had a copy of my download. still with the original name that I had Copied.
I verified the jar was currupt.
I DLed it again. Now I have the function back!
Thanks a bunch.

Dani thanks for your Input.
I'm I will study your examples.
Anything I can get.

Thanks again.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

8

Friday, July 19th 2013, 10:19pm

I know it is a bit of an overkill but this has proven to be reliable on Win and Mac with the compiled program:


Nice.

As of
http://stackoverflow.com/questions/93993…n-of-a-jar-file
I think, this would be a better one:

Jabaco Source

1
MsgBox New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath


Should it be the output for App.Path?
Or CurDir?
Or both?
And if for both, what will be the current output of CurDir should be called? UserDir oder UsrDir?

Greatings
theuserbl

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

9

Friday, July 19th 2013, 10:33pm

Seems, that the first Version from Manuel shows already the right directory. OlimilO changed it to the user dir:
https://code.google.com/p/jabacoframewor…App.jsrc&old=33

And here an implementation, which is a mix of the last one which I have posted and that of Manuels implemenation:

Jabaco Source

1
MsgBox New java#io#File(getClass.getResource(".").toURI.getPath).getAbsolutePath


Greatings
theuserbl

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

10

Friday, July 19th 2013, 10:42pm

Quoted

OlimilO changed it to the user dir:


Ok.
https://code.google.com/p/jabacoframewor…p.jsrc&start=56

Manuel have used the user-dir. Then OlimilO comes up, with the immplementation of the application directory. And that he changed it back to something, what Manuel have implemnented first.

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

11

Friday, July 19th 2013, 10:46pm

Hmm,
I believe it should be App.Path since we are looking for the path to the executable (where the executable and possible other files, e.g.databasefiles are stored)!
CurDir is the current directory of a drive and might change during the lifecycle of our executable.

We might also use TmpDir (e.g.: C:/Users/Administrator/AppData/Local/Temp/Jabaco226808232/) but I don't know if that is relevant during runtime. Maybe for debuging though!?


Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

12

Friday, July 19th 2013, 11:06pm

this seems to be working accurately

Jabaco Source

1
New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath


this does not

Jabaco Source

1
New java#io#File(getClass.getResource(".").toURI.getPath).getAbsolutePath


did not test on Mac yet...


Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

13

Friday, July 19th 2013, 11:11pm

by the way

Jabaco Source

1
New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath


still has the executables name at the end so we have to strip that to get the path. Like I did with my first approach.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

14

Thursday, August 29th 2013, 5:29pm

Ok, and now again a new version of Jabaco.jar:
[ Jabaco-rev109.jar ]

Now there existing a functional App.Path and App.JabacoFrameworkPath

Greatings
theuserbl

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

15

Thursday, September 5th 2013, 12:55pm

App.Path

I'm a bit surprised nobody responded about this last .jar update Jabaco-rev109.jar
Maybe it's just me or my machine, but this code doesn't work for me.

Source code

1
2
3
4
5
Public Sub Form_Load()
   Dim gLP As String
   gLP = App.Path
   Debug.Print gLP
End Sub


It used to.
But now it makes Jabaco enter an unending pause.

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

16

Thursday, September 5th 2013, 11:32pm

RE: App.Path

Maybe it's just me or my machine, but this code doesn't work for me.


Hmmm.. don't know why.

But it works, if you don't run it direct after start:

Jabaco Source

1
2
3
4
5
Public Sub Command1_Click()
   Dim gLP As String
   gLP = App.Path
   Debug.Print gLP
End Sub


But integrating it direct on that position, it works at the start:

Jabaco Source

1
2
3
4
5
Public Sub Form_Load()
   Dim gLP As String
   gLP = New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath
   Debug.Print gLP
End Sub


Currently I don't know why it is so.
Thanks for your testing.

Greatings
theuserbl

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

17

Friday, September 6th 2013, 12:15am

Hmmm... needs a little bit longer to find it out.

This one works:

Jabaco Source

1
2
3
Public Sub Form_Load()
  MsgBox getClass
End Sub


But if I want ask in an external class, then getClass() gives out the place of the class, where it stands in. In case of the JabacoFramework it is VB#App.
And VB#App is, where the JabacoFramework is. But I want to know the place of the own program. That is the file with the main() method and which will be started.


This gives out that class file:

Jabaco Source

1
2
3
Public Sub Form_Load()
  MsgBox System.getProperty("sun.java.command")
End Sub

As you can see, this stands in Form1 and outputs Module1.

But sadly on this point it hangs:

Jabaco Source

1
2
3
Public Sub Form_Load()
  MsgBox Class.forName(System.getProperty("sun.java.command"))
End Sub


If it is not direct on start. For example after clicking a CommandButton, it works:

Jabaco Source

1
2
3
Public Sub Command1_Click()
  MsgBox Class.forName(System.getProperty("sun.java.command"))
End Sub


I hoped, that the problem will be existing with a port to Java, too. Then I could asks some Java-people about the problem.
But the Java-version works perfect:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import javax.swing.*;

public class Test extends JFrame {

  public Test(String s) {
    super(s);
    try {
      System.out.println(Class.forName(System.getProperty("sun.java.command")));
    } catch (ClassNotFoundException e) {
      System.out.println("*** Error: " + e);
    }
    //System.out.println(this.getClass());
  }


  public static void main(String[] args) {
     Test f = new Test("My Window");
     f.setSize(100,100);
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.setVisible(true);
  }

}



And with two different files, it works, too:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import javax.swing.*;

public class MyFrame extends JFrame {

  public MyFrame(String s) {
    super(s);
    try {
      System.out.println(Class.forName(System.getProperty("sun.java.command")));
    } catch (ClassNotFoundException e) {
      System.out.println("*** Error: " + e);
    }
    //System.out.println(this.getClass());
  }

}

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
import javax.swing.*;

public class Test {

  public static void main(String[] args) {
     MyFrame f = new MyFrame("My Window");
     f.setSize(100,100);
     f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     f.setVisible(true);
  }

}


So it needs a little bit longer, to find out, where the reason for that problem is...

Greatings
theuserbl

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

18

Tuesday, September 10th 2013, 6:37pm

Try out
[ Jabaco-rev111.jar ]
Bug was fixed. There still existing some little bugs with App.Path, but for most cases it works.
Test it!
And App.JabacoFrameworkPath works since rev 109.

To fix the problem a german Java community have helped me:
[ http://forum.byte-welt.net/threads/10058…s-forName%28%29 ]

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

19

Tuesday, September 10th 2013, 7:32pm

Thanks a lot theuserbl...

Quoted

To fix the problem a german Java community have helped me:
[ http://forum.byte-welt.net/threads/10058…s-forName%28%29 ]:

Ich meinte, dass das nur 'ne Übung sein kann bzw. sein sollte, zumindest was die Klassen "Modul1" und "Form1" angeht.
1. Die Sache mit dem statischen JFrame (Form1)
2. Den JFrame noch nicht mal auf dem EDT konstruiert
3. Der MessageDialog bei jeder neuen Form
4. "setVisible()" in einem Konstruktor
5. Das sind alles NoGos und nur zu Übungszwecken oder KSKBs geeignet. Wenn man sucht, findet man gewiss noch andere Dinge.


I don't know how to take this!

Hmm, da kommt man sich ja doch sehr hobbymäßig vor!?


Dani

Perry

Beginner

  • "Perry" is male
  • "Perry" started this thread

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

20

Wednesday, September 11th 2013, 7:10pm

App.Path

I'm sorry to be a PITB
It's obvious you guys are working on this pretty hard.
I was testing the new .jar version 111 and was expecting something other than what I got.
No it didn't hang, but it also didn't yield the expected result.
If I for instance use the App.Path command in a program, and place that program on a flash drive, or any other drive, shouldn't it yield the path to the folder of the operating program?
If the folder where I place the program is in "F:\Foldername\", App.Path should return "F:\Foldername\"
Yet this is not the result I recieved when I ran it under Jabaco.
I hoped that maybe the program should be compiled and saved, then if I ran the executable it would then return the proper result.
That failed also.
There was one version ( 105 ) where this worked properly. Where was this changed? We might have to go back and study that?

Rate this thread
WoltLab Burning Board