Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
Menu
Vaadin Self-Changing - App Version Component

Vaadin Self-Changing – App Version Component

Posted on June 23, 2024June 23, 2024 by Toma Velev

Here you have – the source code of Java Vaadin App Version Component with a main method that executes Self-Changing  functionality.

package com.programtom.my_app.views;

import com.vaadin.flow.component.html.Div;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

public class AppVersionComponent extends Div {

static final String version = "2";
static final String date = "2024-06-23 19:46:59";

static final DateFormat df = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");

public AppVersionComponent() {
super("Version: " + version + " Released: " + date);
}

public static void main(String[] args) throws IOException {
File file = new File(System.getProperty("user.dir") + File.separator+"src"+ File.separator+"main"+ File.separator+"java"+ File.separator+"com"+ File.separator+"programtom"
+ File.separator+"my_app"+ File.separator+"views"+ File.separator+"AppVersionComponent.java");
List<String> strings = Files.readAllLines(file.toPath());
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).startsWith(" static final String version = ")) {
String substring = strings.get(i).substring(strings.get(i).indexOf("\"") + 1, strings.get(i).lastIndexOf("\""));
int vInt = Integer.parseInt(substring);
strings.set(i, " static final String version = \"" + (vInt + 1) + "\";");
}
if (strings.get(i).startsWith(" static final String date = ")) {
strings.set(i, " static final String date = \"" + df.format(new Date()) + "\";");
}
}

Files.write(file.toPath(), strings.stream().collect(Collectors.joining("\n")).getBytes(StandardCharsets.UTF_8));
}
}

Change my_app with your package and file path – according to your needs. you could plug this in 

java.exe -cp compiledversionofyourapp.jar -Dloader.main=com.programtom.my_app.views.AppVersionComponent org.springframework.boot.loader.PropertiesLauncher

I’m planning to integrate it in some of my apps: https://programtom.com/dev/product-category/technologies/spring-boot-framework/?orderby=date-desc

I’ve also developed flutter_upgradable_plugin: https://github.com/tomavelev/flutter_updateable_plugin some time ago. I’m planning to update in near future.

  • Prompt-to-Production: How AI is Forcing Us to Build Higher Quality Software
  • Debug Web View Flutter App
  • Skipping AI? You’re a Relic – Time to Evolve or Perish!
  • 2026 Flutter Launch Blueprint: Your 10-Step Checklist to App Store Domination
  • Product Requirements Document – for different software development levels

Categories

  • Apps (25)
  • ChatGPT (27)
  • Choosing a Framework (38)
  • Flutter (281)
  • Graphical User Interface (14)
  • Marketing (119)
  • Software Development (292)
  • Spring (45)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (16)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (87)
    • Flutter Apps (26)
    • GPT (4)
    • Java (39)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (36)
    • Utils (15)
    • Vaadin 24+ (28)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • Prompt-to-Production: How AI is Forcing Us to Build Higher Quality Software
  • Debug Web View Flutter App
  • Skipping AI? You’re a Relic – Time to Evolve or Perish!
  • 2026 Flutter Launch Blueprint: Your 10-Step Checklist to App Store Domination
  • Product Requirements Document – for different software development levels

Post Categories

  • Apps (25)
  • ChatGPT (27)
  • Choosing a Framework (38)
  • Flutter (281)
  • Graphical User Interface (14)
  • Marketing (119)
  • Software Development (292)
  • Spring (45)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (16)