You are not logged in.

sreesog

Beginner

  • "sreesog" started this thread

Posts: 11

Date of registration: Apr 26th 2014

  • Send private message

1

Sunday, April 27th 2014, 4:15pm

Is there a way to export Jabaco code as Java code?

Hi,
I would like to know is there a way to export Jabaco code a Java code - I mean in to text files containing Java code. I know that Jabaco converts the written VB code to equivalent Java code, but the question is, is there a way to get it as Java code itself.
Thanks and regards,
Sreenadh

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Sunday, April 27th 2014, 6:18pm

I would like to know is there a way to export Jabaco code a Java code - I mean in to text files containing Java code.
Currently not. But you can try to decompile some jar-files created by Jabaco for example with [ JD GUI ]. Mostly it can't decompile jar-files created by Jabaco. But sometimes it works. You have more success, if you run your program in the IDE and then decompile the files, which you will find in the directory, which will be opened, when you clicked in the menu "Project" -> "Open Working Directory".

Quoted

I know that Jabaco converts the written VB code to equivalent Java code,
Thats wrong. Jabaco converts (or compiles) written VB code to equivalent Binary-code for the JavaVM.
So, it creates direct from the Sourcecode, the .class-files or .jar-files, without creating .java-files.

Greatings
theuserbl

sreesog

Beginner

  • "sreesog" started this thread

Posts: 11

Date of registration: Apr 26th 2014

  • Send private message

3

Tuesday, April 29th 2014, 6:26am

Hi theuserbl,
Thanks for the informative reply. I created a small program with a button and a Msgbox "Hai" in Jabaco, created a jar file from the same (using File->Make Project) and then decompiled the jar using jd-gui. But I couldn't locate "Hai" anywhere, eventhough I could find a Form1.class and a Command1_Click() among the decompiled files. Where should I look for it?
Note: I am trying to understand Jar and the decompiled code generated from the same in a better way.
Thanks and regards,
Sreenadh

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

4

Tuesday, April 29th 2014, 7:33am

I created a small program with a button and a Msgbox "Hai" in Jabaco,
Ok, I have now doing the same:

Jabaco Source

1
2
3
Public Sub Command1_Click()
   MsgBox "Hai"
End Sub



Quoted

created a jar file from the same (using File->Make Project) and then decompiled the jar using jd-gui. But I couldn't locate "Hai" anywhere, eventhough I could find a Form1.class and a Command1_Click() among the decompiled files. Where should I look for it?
You are already there. If you decompile it with JD-GUI, then this is the output:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import VB.Form;

public class Form1
  extends Form
{
  private Form1.CommandButton Command1;
  
  /* Error */
  public void Command1_Click()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: ldc 221
    //   4: invokestatic 227	VBA/Interaction:MsgBox	(Ljava/lang/String;)LVBA/VBMsgBoxResult;
    //   7: pop
    //   8: nop
    //   9: return
    //   10: nop
    //   11: aload_1
    //   12: checkcast 229	java/lang/Throwable
    //   15: invokestatic 232	VBA/Interaction:MsgBox	(Ljava/lang/Throwable;)V
    //   18: goto -10 -> 8
    //   21: astore_2
    //   22: astore_1
    //   23: ret 2
    //   25: jsr -4 -> 21
    //   28: goto -18 -> 10
    // Line number table:
    //   Java source line #3	-> byte code offset #0
    //   Java source line #4	-> byte code offset #2
    //   Java source line #5	-> byte code offset #8
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	31	0	Me	Form1
    //   0	12	1	Err	java.lang.Throwable
    //   21	1	2	localObject	java.lang.Object
    // Exception table:
    //   from	to	target	type
    //   2	8	25	finally
  }
  
  private void initVars() {}
}


The error says, that JD-GUI can't decompile it, so it disassembles the part. To find your string, you can use javap of the JavaJDK. That gives out following, when you use it with the option "-c":

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Compiled from "Form1.jsrc"
public class Form1 extends VB.Form {
  public void Command1_Click();
    Code:
       0: aconst_null   
       1: astore_1      
       2: ldc           #221                // String Hai
       4: invokestatic  #227                // Method VBA/Interaction.MsgBox:(Ljava/lang/String;)LVBA/VBMsgBoxResult;
       7: pop           
       8: nop           
       9: return        
      10: nop           
      11: aload_1       
      12: checkcast     #229                // class java/lang/Throwable
      15: invokestatic  #232                // Method VBA/Interaction.MsgBox:(Ljava/lang/Throwable;)V
      18: goto          8
      21: astore_2      
      22: astore_1      
      23: ret           2
      25: jsr           21
      28: goto          10
    Exception table:
       from    to  target type
           2     8    25   any

  public Form1();
    Code:
       0: aload_0       
       1: invokespecial #12                 // Method VB/Form."<init>":()V
       4: aload_0       
       5: invokevirtual #15                 // Method initVars:()V
       8: nop           
       9: return        
}


This means, behind the address #221 is your string "Hai". And it is called with ldc.

But again: I sayd, you will have been better results, if you decompile the classes created in "Project" -> "Open Working Directory".
In this case, JD-GUI can decompile the program:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import VB.Form;
import VBA.Interaction;

public class Form1 extends Form
{
  private Form1.CommandButton Command1;

  public void Command1_Click()
  {
    Throwable Err = null;
    Interaction.MsgBox("Hai");
  }

  private void initVars()
  {
  }
}


It is also not really correct, because the method "initVars()" isn't really empty. But it shows enough of the code.

To have a better overview, you have to use different decompilers:
Additional to JD-GUI for example
JAD: [ http://varaneckas.com/jad/ ]
FernFlower: [ http://forum.xda-developers.com/showthread.php?t=2029842 ]
etc.

Greatings
theuserbl

This post has been edited 1 times, last edit by "theuserbl" (Apr 29th 2014, 7:50am)


sreesog

Beginner

  • "sreesog" started this thread

Posts: 11

Date of registration: Apr 26th 2014

  • Send private message

5

Tuesday, April 29th 2014, 1:05pm

Wow! That was an excellent reply! Thanks a lot.
I hope that in future versions Manuel will provide us with a way to export the code to Java too.

Rate this thread
WoltLab Burning Board