B4J Question Can I recompile generated Java source in Web App ?

severika

Member
Licensed User
Longtime User
Hello,

I have created a simple B4J Web app, it works fine on a remote Linux server (using java -jar myapp.jar).

Now I want to make a small change in one of the Java source files in src folder, and rebuild the jar, using javac (?) (no B4J available on the server).
I would like the jar to contain the Jetty server also, so that it could run.

Can I do that ? how ?
My files in /Objects/src/b4j/example/ folder are as :
- main.java
- handlerclass1.java
- handlerclass2.java


Thank you.
 

severika

Member
Licensed User
Longtime User
add the needed things on your pc using B4J, compile a new jar and use this new jar on your server.

Thank you for reply.
But what if I can't access my B4J machine, and I need to change the application really fast ?

I can only assume there are some B4J jars that I will need to put in a "libs" folder on the server, and then run something like :
javac -classpath ./libs main.java ??

Or there is some XML that I wiould need to use in my build, so that it links all the java files ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Changing the generated Java code is a mistake. This is especially true for someone with this avatar

You can install B4J on any Windows computer. To save a bit of uploading time you can set #MergeLibraries: False and upload the libraries to the server once. This way the project jar will be very small.
 
Upvote 0

severika

Member
Licensed User
Longtime User
Changing the generated Java code is a mistake.

This is very unlikely to happen, I want to stay as far away from Java as possible
However, still this would be very productive, I am only asking for small changes, not major code changes.
I think everyone wants to fix stuff fast, don't we ?

So the question remains, can I do it ? how ?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I think everyone wants to fix stuff fast, don't we ?
Sure, but even more, I want my fixes to be reliable! And that is by going through the right channels, in this case recompile with B4X. I can hardly imagine your 'direct' way will be any faster than just recompiling with B4J and uploading the new jar. And it will guarantee it will run...
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I've not run across one issue yet I had in any of my projects (please note they are mostly small scale projects) where I felt the need to modify/"correct" the transpiled code. I've looked at the code at times to determine HOW B4X implements something and therefore gain a better understanding of the platform itself, helping me to write better B4X code. And how hard is it to create a new jar file on your machine and upload it to the server? BTW, what you are suggesting is to upload your whole source tree to the server, since without it you could not even do what you wanted to do. So now you need a plan to keep the source between your machine and the server in sync. So if you ever update your .jar file and forget to upload the current source with it, any updates to the source on the server would just be for naught and would actually roll back your application. Are you sure you thought this all the way through?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…