Why did the quality of the GUI deteriorate by half after creating the exe file with jpackage? - libgdx

I'm using jpackage to convert the jar file to an exe, with the exe file provided by the internal JRE. As a result of the conversion, good results were obtained, the JRE weighs about 38.5 mb.
When I run the exe, the GUI quality is twice as WORSE as in a normal jar! In addition, the window of the new exe file increases on its own. Thus, very strange changes appear, as if the exe file is trying to imitate a window jar file. I want to point out that I am using libGdx for the GUI.
desktop gradle:
{
plugins { id 'org.beryx.runtime' version '1.8.4' }
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../android/assets"]
mainClassName = "com.iapp.chess.desktop.DesktopLauncher"
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
project.ext.assetsDir = new File("../android/assets")
task runGame(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"
runtime {
options = ['--strip-debug',
'--compress', '2',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
'--vm', 'server']
modules = ['java.base',
'java.desktop',
'jdk.unsupported']
distDir = file(buildDir)
jpackage {
jpackageHome = 'C:\\Program Files\\Java\\jdk-17.0.2'
mainJar = dist.archiveFileName.get()
if (osName.contains('windows')) {
imageOptions = ["--icon", file("../icons/icon.ico")]
} else if (osName.contains('linux')) {
imageOptions = ["--icon", file("../icons/icon.png")]
} else if (osName.contains('mac')) {
imageOptions = ["--icon", file("../icons/icon.icns")]
}
}
}
}

Related

File creation Kotlin Android 12 not working without device restart

I am new to Android, I am trying to create 3 json files in device documents directory on app installation if the files do not already exist which they wont.
Problem is that the below sequence works in creating files successfully
device restart
app install
But following sequence is not able to create the files
app uninstall
manual file deletetion from devise
app install
what is going wrong?
Below is the code i am using to create file:
private fun createDirectory() {
val Dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)
if (!Dir.exists()) {
Dir.mkdirs()
}
//create all files
val IncomeFile = File(Dir, "Income.json")
if(!IncomeFile.exists()) {
val data: String = "{\"Incomes\":[]}"
val out: FileOutputStream = FileOutputStream(IncomeFile)
out.write(data.toByteArray())
}
val InvFile = File(Dir, "Investments.json")
if(!InvFile.exists()) {
val data: String = "{\"Investments\":[]}"
val out: FileOutputStream = FileOutputStream(InvFile)
out.write(data.toByteArray())
}
val ExpensesFile = File(Dir, "Expenses.json")
if(!ExpensesFile.exists()) {
val data: String = "{\"Expenses\":[]}"
val out: FileOutputStream = FileOutputStream(ExpensesFile)
out.write(data.toByteArray())
}
}
I have the permission request before this:
private fun askPermission() {
ActivityCompat.requestPermissions( this, arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE),
PackageManager.PERMISSION_GRANTED)
}
I have the uses in manifest file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Tried createFile and file.write(text) both not able to create new files.

Building a nix derivation within a module

I created the following module services/invidious.nix
{ pkgs, stdenv, ... }:
stdenv.mkDerivation {
name = "invidious";
container = pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/bash" ];
Env = [];
Volumes = {};
};
};
}
My eventual goal is to have several services in modules and use nix-build to build each of those services as containers, and write the resulting image names to a file:
let
config = import ./config.nix;
pkgs = config.pkgs;
invidious = import ./services/invidious.nix;
in rec {
serviceimages = pkgs.writeText "images.txt" ''
${invidious(pkgs)}
'';
}
and my config.nix just has the pkgs pinned version:
{
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
}
However, when I use nix-build, I get the following error:
nix-build services.nix -A serviceimages
these 2 derivations will be built:
/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
/nix/store/4x31hx9nxcbbksi2hsim08djrsj4h1zh-images.txt.drv
building '/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv'...
unpacking sources
variable $src or $srcs should point to the source
error: builder for '/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv' failed with exit code 1;
last 2 log lines:
> unpacking sources
> variable $src or $srcs should point to the source
For full logs, run 'nix log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv'.
If I try to pull the full logs using the command given, I get the following:
nix log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
...and if I enable the experimental feature, I see the following:
nix --extra-experimental-features nix-command log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
#nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
variable $src or $srcs should point to the source
If I just try to build the same service in a single file, it successfully builds the image:
let
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
in rec {
docker = pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/sh" ];
Env = [];
Volumes = {};
};
};
results = pkgs.writeText "images.txt" ''
${docker}
'';
}
What am I doing wrong with my attempt to use modules?
I figured it out. I didn't need the mkDerivation. I just need the buildLayeredImage
{ pkgs, ... }:
pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/bash" ];
Env = [];
Volumes = {};
};
}
The service.nix and config.nix stay the same:
let
config = import ./config.nix;
pkgs = config.pkgs;
invidious = import ./services/invidious.nix;
in rec {
serviceimages = pkgs.writeText "images.txt" ''
${invidious(pkgs)}
'';
}
{
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
}

Gradle Kotlin Build Script unable to get SpringBoot Lib

i tried few way on my build script but still unsuccessful to get the springboot lib in to my jar, may i know what's wrong with my script as below ?
Parent Gradle Kotlin DSL
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
extra["kotlin.version"] = "1.3.31"
plugins {
java
idea
id("org.springframework.boot") version "2.1.4.RELEASE" apply false
kotlin("jvm") version "1.3.31" apply false
kotlin("plugin.spring") version "1.3.31" apply false
}
subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
apply(plugin = "io.spring.dependency-management")
the<DependencyManagementExtension>().apply {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
group = "com.company.market"
version = System.getenv("VERSION") ?: "0.2-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
repositories {
maven {
credentials {
username = "anonymous"
password = "anonymous"
}
url = uri("http://repo1.maven.apache.org/maven2/")
}
}
dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib-jdk8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.getByName<KotlinCompile>("compileKotlin") {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
tasks.getByName<KotlinCompile>("compileTestKotlin") {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
}
Child (API) Gradle Kotlin DSL
Here are the child module that will used for deployment
plugins {
`java`
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.security.oauth:spring-security-oauth2:2.3.3.RELEASE")
implementation("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.4.RELEASE")
implementation("org.springframework.boot:spring-boot-devtools")
implementation("org.apache.commons:commons-dbcp2")
implementation("org.mariadb.jdbc:mariadb-java-client")
implementation("org.springframework.boot:spring-boot-loader:2.1.4.RELEASE")
implementation(project(":app-expr"))
implementation(project(":app-data"))
}
i can success build the api module but jar size is small and realize the lib were not build inside the jar.
i added the springboot lib in my sub proj and solved
plugins {
`java`
id("org.springframework.boot")
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.security.oauth:spring-security-oauth2:2.3.3.RELEASE")
implementation("org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.4.RELEASE")
implementation("org.springframework.boot:spring-boot-devtools")
implementation("org.apache.commons:commons-dbcp2")
implementation("org.mariadb.jdbc:mariadb-java-client")
implementation("org.springframework.boot:spring-boot-loader:2.1.4.RELEASE")
implementation(project(":expr"))
implementation(project(":data"))
}

GCP compute_engine network interface terraform error

My terraform file looks like this:
resource "google_compute_instance" "virtual_instance" {
name = "${var.instance_name}"
machine_type = "${var.instance_type}"
zone = "${var.zone}"
lifecycle {
ignore_changes = ["boot_disk.0.initialize_params.0.image"]
}
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1604-lts"
size = "30"
type = "pd-standard"
}
}
network_interface {
network = "default"
access_config {}
}
attached_disk {
source = "${google_compute_disk.managed_data_disk.name}"
mode = "READ_WRITE"
}
metadata {
}
}
This above code created the instance. But when i change then network_interface block as mentioned below
network_interface {
network = "${module.vpc.vpc_name}"
subnetwork = "${module.vpc.subnet_name}"
access_config {}
}
The VPC module is :
resource "google_compute_network" "vpc" {
name = "${var.name}-vpc"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "subnet_public" {
name = "${var.subnet_name_public}"
ip_cidr_range = "${var.subnet_cidr_public}"
network = "${var.name}-vpc"
depends_on = ["google_compute_network.vpc"]
region = "${var.region}"
}
resource "google_compute_firewall" "firewall" {
name = "${var.name}-firewall"
network = "${google_compute_network.vpc.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["0.0.0.0/0"]
}
when I changed into network_interface to custom values. It's throwing the error is
google_compute_instance.virtual_instance: Error creating network interfaces: exactly one of network or subnetwork must be provided
Please help me on this
Advance Thanks to #ydaetskcoR. If you choose custom values of network_interface. You can't mention both network and subnetwork. You will choose only subnetwork values mentioned below.
network_interface {
subnetwork = "${module.vpc.subnet_name}"
access_config {}
}

how to streamWrite a .zip/epub file from response to isolatedStorage if that .zip/hpub file contains .jpg, .woff (web open font format)

Actually i am trying to saving a .zip/.epub file from webResponse into my wp8 isolated storage which contains saveral .html, .png, .jpg and .woff ( Web Open Font Format) files.
my following code is saving only .html and .png files from the .zip/.epub, when it try to save .jpg and .woff format files it shows following exception.
Exception: Operation not permitted on IsolatedStorageFileStream BinaryWritter
Please help me to solve that how to streamWrite myFont.woff file ?
my code is following.
private async void ReadWebRequestCallback(IAsyncResult ar)
{
IsolatedStorageFile myIsoStorage = IsolatedStorageFile.GetUserStoreForApplication();
string dir = "/mainDir/subDir/subtosubDir";
if (!myIsoStorage.DirectoryExists(dir))
{
myIsoStorage.CreateDirectory(dir);
}
HttpWebRequest myRequest = (HttpWebRequest)ar.AsyncState;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(ar);
using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
{
using (ZipInputStream s = new ZipInputStream(httpwebStreamReader.BaseStream))
{
ZipEntry theEntry;
try
{
while ((theEntry = s.GetNextEntry()) != null)
{
if (theEntry.IsDirectory)
{
string strNewDirectory = dir+"/"+theEntry.Name;
if (!myIsoStorage.DirectoryExists(strNewDirectory))
{
myIsoStorage.CreateDirectory(strNewDirectory);
}
}
else if (theEntry.IsFile)
{
string fileName = dir + "/" + theEntry.Name;
//save file to isolated storage
using (BinaryWriter streamWriter = new BinaryWriter(new IsolatedStorageFileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, myIsoStorage)))
{
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
}
}
}
}
catch (Exception ze)
{
Debug.WriteLine(ze.Message);
}
}
}
}
using (IsolatedStorageFileStream fileStream = isf.OpenFile(fullFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
s.CopyTo(fileStream);
}
In my case it is the only way to save different extension's files into the isolated Storage, BinaryWriter will not work. so #KooKiz was right.
Thanks Kookiz :)