#sdkman
Explore tagged Tumblr posts
Text
How to Manage Your JDKs With SDKMAN
How to Manage Your JDKs With SDKMAN
In this blog, you will learn how to manage several Java Development Kits (JDKs) on your Linux system using SDKMAN. Besides JDKs, several other SDKs can be managed by means of SDKMAN. Enjoy! 1. Introduction Some time ago, a colleague of mine showed me how he used SDKMAN and how easy he could maintain different versions of JDKs, Maven, etc. on his Linux system. I had heard of SDKMAN before but did…
View On WordPress
0 notes
Text
How to install x86 and Arm JDKs on the Mac M1 (Apple Silicon) using SDKMAN!
SDKMAN! is a great tool to install and manage different versions of JDK from different vendors. Now you can install Arm JDKs on the M1
Right now several OpenJDK vendors like AdoptOpenJDK, Azul, and Microsoft offer MacOS ARM builds of OpenJDK on their website. SDKMAN! has started to support Arm JDKs on the Apple Silicon from version 5.10.0
Read more…
0 notes
Text
Developers Needs SDKMAN Not Super-Man
Every developer has pain for setup development environment to his/her machine with lots of the setups. Sometimes, the pain goes beyond while we need to test same application on multiple versions of SDKs or virtual machines.
If you are a Mac user, you have the best option called brew installer.
But if you are Linux user, your pain is unpredictable.
We are Java developers and Linux users and…
View On WordPress
#Clojure#gradle#grails#groovy#java#jdk#kotlin#linux#Manager#maven#openjdk#opensource#packages#sbt#scala#sdkman#Spark#Spring#springboot#technology#vertx
0 notes
Text
sdk man!!!
Recently I came up with sdkman.io which is more like a version manager for java, scala, groovy, maven etc
Lastly I was using nvm (node version manager) which resembles the same
0 notes
Text
Openjdk 14 download
Openjdk 14 download how to#
Openjdk 14 download license#
You should be running one of the supported release numbers listed above in the rightmost column. Older releases, which do not include the most up to date security vulnerability fixes and are no longer recommended for use in production, remain available in the OpenJDK Archive. More information is available on the Java/OpenJDK website. Other projects such as Adoptium or Linux distributions may provide builds external of Oracle and are governed under the open source license. Only the very latest Java release is available pre-built with the open source license, one must purchase support to get builds from Oracle for 8 or 11.
Openjdk 14 download license#
Official builds and support from Oracle come in two varieties: open source under the GNU GPL, and a proprietary license that must be purchased. The latest supported release in each release cycle can be found at. Non-LTS releases are supported for 6 months. Download the latest JDK(jdk-11.0.14linux-圆) from the. Supported platforms include Linux, macOS. Even though OpenJDK is available in Linux repositories, some applications strictly. Java 8 is the last release on the old cycle methodology still in active support. AdoptOpenJDK provides prebuilt OpenJDK binaries from a fully open source set of build scripts and infrastructure. Java as developed by the OpenJDK Project, owned and primarily employed by Oracle, has been on a 6-month rapid-release cycle since the release of Java 10, and starting with Java 11, has new LTS releases every six releases, or three years. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. which java /home/raj/.sdkman/candidates/java/current/bin/java > java -version openjdk 14 OpenJDK Runtime Environment (build 14+36-1461) OpenJDK. Open the JDK 14 GA Release site and download the distribution for Windows as. Added tag jdk-14-ga for changeset bc54620a3848 default tip: Fri, 00:17:01 +0100: jwilhelm: Added tag jdk-14+36 for changeset bc54620a3848: Thu, 10:10:54 -0800: naoto: 8238605: Correct the CLDR version number in cldr.md files jdk-14+36 jdk-14-ga: Thu, 02:52:17 +0100: jwilhelm: Added tag jdk-14+35 for changeset.
Openjdk 14 download how to#
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. How to Install Java OpenJDK 14 on macOS Catalinasudo mv openjdk-14.0. This site uses Just the Docs, a documentation theme for Jekyll.
0 notes
Text
How to install java 8 mac
#How to install java 8 mac how to#
#How to install java 8 mac for mac#
#How to install java 8 mac install#
Set a global Java version: asdf global java openjdk-17 List your installed versions: asdf list java
#How to install java 8 mac install#
Or install the latest: asdf install java latest Install your favorite flavor and version: asdf install java openjdk-17 Now list Java versions: asdf list-all java Basically it says to add the following to your ~/.zshrc file (assuming you are not using another shell). Then install the Java plugin via asdf plugin add javaĪnd read the doc for setting up your shell correctly before continuing. $(brew -prefix asdf)/libexec/asdf.sh" > $/.zshrc It has language specific plugins including one for Java.įirst, install asdf via (read there to setup your shell correctly), or more simply: brew reinstall asdfĪnd read the doc for setting up your shell correctly, but if you are using asdf from Homebrew with ZSH you can execute this command to finish setup: echo -e " . Installing and Switching versions with " asdf"Īsdf is a version manager that supports installing and managing most languages, frameworks, and developer/devops tools. More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage. And as a note, it installs Java versions to ~/.sdkman/candidates/java/. SDKMAN will automatically manage your PATH and JAVA_HOME for you as you change versions. Just do a local install giving your own version label and the location of the JDK: sdk install java my-local-13 /Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/HomeĪnd use it freely: sdk use java my-local-13 SDKMAN can work with previously installed existing versions. When you list available versions for installation using the list command, you will see a wide variety of distributions of Java: sdk list javaĪnd install additional versions, such as JDK 11 from Amazon: sdk install java 11.0.14.10.1-amzn Or switch to 17 for the current terminal session: sdk use java 17-open Make Java 17 the default version: sdk default java 17-open Install one of those versions, for example, Java 17 LTS: sdk install java 17-open List the Java versions available to make sure you know the version ID sdk list java SDKMAN allows setting a global default version, and a version specific to the current shell. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java. SDKMAN is a bit different and handles both the install and the switching. Installing and Switching versions with SDKMAN These two primary options are described here. However, there are easier options such as SDKMAN and asdf that also will install other important and common tools for the JVM.
#How to install java 8 mac for mac#
The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX. You can install Java using whatever method you prefer including SDKMAN, asdf, Homebrew, or a manual install of the tar.gz file. TL DR - Preferred Methods of Installation Switching can be done by JEnv, SDKMAN, asdf, Jabba or manually by setting JAVA_HOME. Installation can be done by Homebrew, SDKMAN, asdf, Jabba, or a manual install.
#How to install java 8 mac how to#
You have a few options for how to do the installation as well as manage JDK switching. Easily work with Java 7, Java 8, Java 9, Java 10, Java 11, Java 12, Java 13, Java 14, Java 15, Java 16, Java 17, and even Java 18! This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more. Note: These solutions work for various versions of Java including Java 8 through Java 18 (the LTS version).
0 notes
Text
Java download for mac
JAVA DOWNLOAD FOR MAC INSTALL
JAVA DOWNLOAD FOR MAC CODE
JAVA DOWNLOAD FOR MAC LICENSE
JAVA DOWNLOAD FOR MAC INSTALL
| | 18.ea.3 | open | | 18.ea.3-openĬhoose one and install it using the command sdk install java IDENTIFIER, i.e.: Vendor | Use | Version | Dist | Status | IdentifierĪzul Zulu | | 16.0.1 | zulu | | 16.0.1-zuluīellSoft | | 16.0.1 | librca | | 16.0.1-librca Set sdkman_rosetta2_compatible=false (see sdkman config)Īfter that, you will see a list of compatible with M1 JDKs: sdk list java You can install the Java JDK using sdkman (see sdkman install): vim. Note that Microsoft's been working on the OpenJDK branch of AArch64 (for ARM-based Windows 10) for a while, which goes back to: A lot of the hard work was already done. Microsoft's (yes, really) GitHub source repo for an early access OpenJDK16 build for macOS on AArch64.Donate to the effort or contribute a pull request if you want it to go faster. You didn't pay them, you have no contract, and they don't owe it to you.
JAVA DOWNLOAD FOR MAC CODE
My assumption is that the ARM branch of the OpenJDK source code + the macOS bits that already exist for the macOS 圆4 release can be combined rather easily once someone with some familiarity with the OpenJDK source code has an M1-based macOS system to test it on, which should mean an adoptopenjdk macos-aarch64 release should be here within the month.īut, open source. But, it's an open source effort, so if you're anxious, by all means, read up and contribute :)Īpple has not given any details on this architecture whatsoever until November 10th 2020, unless you bought a development kit box for it (a Mac Mini with an A14 chip, which isn't an M1 chip, but close enough I guess), and signed a big NDA.Īs a rule, open source projects will run as fast as possible in the opposite direction if you wave an NDA around, so if you dislike this state of affairs, I don't think it's wise to complain to adoptopenjdk or other packagers and open source projects about it :)įortunately, now it's out, and an NDA is no longer required. That is to say: It should not be a herculean effort to create an adoptopenjdk release that runs on M1s natively, so presumably, it will happen.
JAVA DOWNLOAD FOR MAC LICENSE
So: It's not there yet, but note that JDKs for ARM have been available for more than decade, and whilst JDK 15 has dropped support for a bunch of exotic OS/architecture combinations (such as Solaris), ARM development has always remained at least partially relevant (even if so far it's mostly an Oracle commercial license offering). That (probably) won't run on macOS on M1 hardware, but that's 95% of the work already done. If you instead leave Operation System on 'any', you'll note aarch64 is in there, and this gets you to a Linux release for ARM processors. Possibly, as Apple no doubt has a bunch of extensions built into their M1 designs, and Apple gets its own. On this page: AdoptOpenJDK Latest Releases you can select 'macOS' from the 'Operating System' dropdown, and then from 'Architecture', it's currently only 圆4, but soonish there should be AArch64 or ARM64 (those are usually the shortcodes for 64-bit ARM).
0 notes
Text
If you have a Unix based system and you would like to use parallel versions of multiple SDK, take a look at SDKMAN:
Install it:
$ curl -s "https://get.sdkman.io" | bash
Check your current java SDK
$ sdk current java
Check your installed SDK:
$ sdk offline enable
$ sdk list java
$ sdk offline disable
if you want to use an specific java version in your current session:
$ sdk use java <version>
but if you want to set that version as the default:
$ sdk default java <version>
This tools is handy and could avoid some headaches, try it out!
https://sdkman.io/usage
0 notes
Text
Build an Ionic 4 App with User Login and Registration
Ionic allows you to develop Progressive Web Applications (PWAs) and hybrid mobile apps. PWAs are web applications that run in a browser and allow for offline capabilities via service workers. They can be installed on desktops and mobile devices, just like you install apps on your smartphone. Hybrid mobile apps are like native mobile apps, except they're built using web technologies.
Ionic 2 was based on AngularJS. Ionic 3 was based on Angular. Ionic 4 allows you to use the most popular JavaScript frameworks available today: Angular, React, or Vue. This article focuses on the Angular version of Ionic 4. I'll show you how to create an Ionic 4 app, add user authentication, and configure things to allow user registration.
If you don't want to code along, feel free to grab the source code from GitHub! You can also watch a video of this tutorial.
Get Started with Ionic 4
To set up your environment to develop with Ionic, complete the following steps:
Install Node.js
Install Ionic CLI using npm
npm install -g [email protected]
Create an Ionic 4 Application
From a terminal window, create a new application using the following command:
ionic start ionic-login tabs
When prompted to install the Ionic Pro SDK, answer no.
It may take a minute or two to create your project, depending on the speed of your internet connection.
Once the process completes, start your Ionic 4 application.
cd ionic-login ionic serve
This command will open your default browser and navigate to http://localhost:8100.
You can use Chrome's device toolbar to see what the application will look like on an iPhone X.
Now let's add a user login feature! Stop the ionic serve process using Ctrl+C before proceeding to the next step.
Add User Login
Schematics is a library from the Angular CLI project that allows you to manipulate projects with code. You can create/update files and add dependencies to any project that has a package.json file. I created an OktaDev Schematics project that makes it possible to add authentication to an Ionic 4 app using one command.
ng add @oktadev/schematics
Before you run this command, you'll need to create an OpenID Connect (OIDC) app in Okta. OIDC builds on top of the OAuth 2.0 authorization framework. It allows clients to verify the identity of the user and get their details. If you're not familiar with OAuth 2.0 or OIDC, I recommend you read What the Heck is OAuth?
Create an OpenID Connect App in Okta
To integrate Okta's Identity Cloud for user authentication, you'll need to signup for a developer account.
Log in to your Okta developer account and navigate to Applications > Add Application.
Select Native and click Next.
Enter a name for your application, such as Ionic 4 App. Add http://localhost:8100/implicit/callback as a Login redirect URI. Click Done to finish creating the application.
Click Edit and add Logout redirect URIs, where the first should be your reversed Okta domain name, followed by :/logout and the second is http://localhost:8100/implicit/logout. Click Save.
Near the bottom of your application's settings, you will find a section titled Client Credentials. Copy the Client ID and paste it somewhere handy. You will need this soon.
Navigate to API > Authorization Servers and copy your issuer URI.
Use OktaDev Schematics to Add User Login
Now that you have a client ID and issuer URI, you can install Angular CLI, and add a user login feature using ng add.
npm i -g @angular/[email protected] ng add @oktadev/schematics --issuer=$issuer --clientId=$clientId
This command performs the following steps:
Adds and installs @oktadev/schematics as a dev dependency
Adds Ionic AppAuth as a dependency
Adds @ionic/storage as a dependency
Adds services, modules, and pages to src/app/auth
Adds a login page and related files to src/app/login
Adds a cordova section to package.json that defines plugins and a custom URL scheme
Updates existing files to handle authentication logic
If you'd like to see the source code for the templates that are installed, you can find them on GitHub.
It's pretty sweet that OktaDev Schematics automates all of this for you, don't you think?!
Test User Login
Start your Ionic 4 application using ionic serve. Your app now has a login button. Click on it to authenticate with Okta using OIDC.
It's likely that you're already logged into your Okta account, so you'll be redirected back to your app and see a screen like the following.
If you click Sign Out and Sign In again, you'll be prompted for your credentials.
After you're redirected back to your app, you can click the User Info button to retrieve your user details from Okta.
Add User Registration
Next, enable user registration. This will allow new users to create their own account. Click on the Users menu and select Registration.
Click Enable Registration.
On the subsequent page, click Save to complete the process of enabling user registration.
Now if you go back to your app, sign out, then sign in again, you'll see a signup link at the bottom of the login form.
Click on the link and you'll see a user registration form. Fill it out and click Register.
You'll receive an email to verify you're real. Click on the Activate Account once you receive it, and you should be good to go!
Run Your Ionic 4 App on iOS
To generate an iOS project for your Ionic application, run the following command:
ionic cordova prepare ios
When prompted to install the ios platform, answer yes. When the process completes, open your project in Xcode:
open platforms/ios/MyApp.xcworkspace
NOTE: If you don't have Xcode installed, you can download it from Apple.
You'll need to configure code signing in the General tab, then you should be able to run in Simulator. Below are screenshots of it running on an emulated iPhone X.
Run Your Ionic 4 App on Android
The most important thing to know when running your Ionic app on Android is that you need Java 8 installed. Anything above Java 8 will not work. If you need to switch between Java SDK versions -- like I often do -- I recommend installing SDKMAN! I ran the command below to downgrade from Java 11 to Java 8 in my terminal window:
sdk use java 8.0.202-amzn
You can then generate an Android project.
ionic cordova prepare android
When prompted to install the android platform, answer yes. After this process completes, open your platforms/android directory as a project in Android Studio.
studio platforms/android
NOTE: You will need to have Android Studio 3.3+ installed and have run Tools > Create Command-line Launcher for the command above to work.
Running with Android Studio 3.3.2
When I first tried this in Android Studio, I received a Gradle Sync error:
The minSdk version should be declared in the android manifest file.
In the right pane, it offered a link for me to click on to fix the issue. I clicked on it, then clicked Do Refactor.
I was prompted to update Gradle and clicked Update.
After these changes, my app showed up in the top toolbar.
Running with Android Studio 3.4
When I tried opening the project in Android Studio 3.4, I was prompted to update Gradle again.
After doing so, I received the following error:
WARNING: The following project options are deprecated and have been removed: android.useDeprecatedNdk NdkCompile is no longer supported
I found an open issue in the Cordova Android project that shows how to fix it. Open android/gradle.properties and turn off useDeprecatedNdk.
android.useDeprecatedNdk=false
Set LaunchMode to singleTask
You need to make one additional change for everything to work properly on Android. You need to set the launchMode from singleTop to singleTask so the URL does not trigger a new instance of the app. Edit platforms/android/app/src/main/AndroidManifest.xml to make this change:
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTask" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
Now you should be able to click the play button in Android Studio to start your app.
You will be prompted to select an existing AVD (Android Virtual Device) or you can plug in your Android phone and use that. If you have neither, click the Create New Virtual Device Button.
Below are screenshots of the app running on a Pixel 2 AVD.
What About Capacitor?
Capacitor is a project from the Ionic folks that offers an alternative to Cordova. It's currently in beta. The OktaDev Schematics project provides support for Capacitor with a --platform=capacitor flag. For example:
ng add @oktadev/schematics --platform=capacitor
NOTE: This integration uses Ionic's native HTTP plugin for Cordova because the default HTTP from Capacitor uses a capacitor://localhost origin header and Okta only supports http origins.
Bonus: You're Using PKCE in the Browser and on Mobile!
The Ionic 4 AppAuth integration in this example uses PKCE (Proof Key for Code Exchange). PKCE (pronounced "pixy") is a security extension for OAuth 2.0 for public clients on mobile (and desktop) clients. It's designed to prevent interception of the authorization code by a malicious application that runs on the same device. You can read about why it's awesome in Aaron Parecki's Is the OAuth 2.0 Implicit Flow Dead?
Learn More About Ionic, Schematics, and Angular
This tutorial showed you how to create an Ionic 4 application and add user login and registration with a handful of commands. If you'd like to see the completed application, you can find it on GitHub.
Ionic's support for React and Vue are in beta at the time of this writing. To read more about them, I recommend the following blog posts:
Announcing the Ionic React Beta
Announcing the Ionic React Beta
I could have shown you how to create 19 files and update 8 to integrate OIDC login in Ionic 4. However, that seems like a long and cruel tutorial. Instead, I streamlined everything by using OktaDev Schematics. The code that OktaDev Schematics uses is from the Ionic AppAuth project's Cordova and Capacitor examples.
I've written a few other tutorials on Schematics that might interest you:
Use Angular Schematics to Simplify Your Life
Use Schematics with React and Add OpenID Connect Authentication in 5 Minutes
Schematics: A Plug-in System for JavaScript Projects
If you're interested in learning more about Angular, the Okta developer blog has some great posts.
Angular 8 + Spring Boot 2.2: Build a CRUD App Today!
Build Secure Login for Your Angular App
Build a Simple Web App with Express, Angular, and GraphQL
Enjoyed this tutorial? Follow me on Twitter @mraible for more like it!
via Scotch.io http://bit.ly/2wbPLiG
0 notes
Link
1. Environment Hardware: MacBook Pro 15-inch laptop (2.5 GHz Intel i7, 16GB 1600 Mhz DDR3, 500GB Flash Storage). Operating System: MacOs Mojave 10.14.2 SDKMAN! for the installation of Micronaut Micronaut 1.0.2 2. Introduction Micronaut is a JVM framework that allows us to create our applications based on microservices in a simple and fast way. In addition to …
0 notes
Text
Install several versions of JDK, Gradle, Kotlin, Scala, Spark and … on your OS in parallel
General-purpose Software Development Kit Manager
You may hear about pyenv, RVM or NVM which allows Python, Ruby, and Node.js developers to have multiple versions of their development environment simultaneously and easily manage them (install and uninstall) and most importantly switch between those versions by running a simple command.
Read more…
0 notes
Photo
Develop an Android App with React Native & Publish on Google Play
This article was originally published on the Okta developer blog. Thank you for supporting the partners who make SitePoint possible.
As mobile app usage is expected to continue to grow, now is as good a time as any to get into the market. Android is by far the most popular OS worldwide and the dominant way to get Android apps to phone users is the Google Play Store. In this tutorial, you’ll build a React Native app and I’ll walk you through everything from how to pick a design, as well as setting up your React Native environment, tips for getting the most out of your editor, and publishing it on Google Play.
This is what the eventual app will look like:
For this tutorial, I checked out Karan Goel’s Mega Project List for project inspiration. You’ll be building the Prime Factorization problem which takes a number and returns its prime factors.
Determine Interface Theming for Your React Native App
Outside of application logic, UI and theming decisions are some of the most important that you’ll make for your app This includes the controls like dropdowns and buttons, as well as the layout on the screen. Since we are using a React-based technology, we’re going to use Styled Components which is a popular, light-weight approach to theming React applications (and it also works great on React Native). There’s an entire page listing components and component-systems based on Styled Components. In this tutorial, you’ll be using Styled Components to build up components yourself.
Set Up Your Android Production Environment
In order to build the eventual APK (the format of the app you’ll upload to the store), you need to install Android Studio. Once done make sure you have SDK version 27 as this is what React Native uses.
Install the JDK
You also need to make sure you have a recent Java Development Kit installed (like version 8). The installation differs depending on your platform. You can use Oracle’s Java SDK or use SDKMAN to install other options, like OpenJDK.
Add the React Native CLI and Initialize the Skeleton
Next, you should install the React Native Command Line Interface. For this, you should make sure you have Node installed which varies depending on your operating system. (I am using version 8.12.0).
npm install -g [email protected]
You should have a command react-native available to you, which includes the init option.
react-native init prime_components
This will create the prime_components directory and put a React Native project inside, with a runnable skeleton. Change to the directory, connect your Android phone or run an emulator (after having installed Android Studio), and run the project.
NOTE: If Android Studio prompts you to open a project before you can create an emulator, you can point to the prime_components/android directory.
cd prime_components react-native run-android
To see the output you’ll upload to the Play Store, go to android/app/build/outputs/apk/debug. You should see an app-debug.apk that is around 8MB in size.
Reduce the Output Size of Your Android App
You want to make sure your users have the smallest download possible. It’s already quite small (around 8MB) because you’re using the command line (something like Expo produces 25MB for even basic apps) but we can reduce it further. Go to android/app/build.gradle and change the following variables to be true:
def enableSeparateBuildPerCPUArchitecture = true def enableProguardInReleaseBuilds = true
You’ll also have to remove the ndk section of defaultConfig to removing the conflicting configuration in ndk abiFilters error:
ndk { abiFilters "armeabi-v7a", "x86" }
Now after re-running react-native run-android you should see two (much smaller - between 4MB and 5MB) APKs in the output directory.
Add Linting to Your React Native App
Writing any JavaScript (like React) requires tools to ensure you haven’t made any obvious mistakes which can be a big help for beginners. The most common of these is ESLint which can be plugged right into your project and editor.
First, add the linter using NPM:
npm install -D [email protected] [email protected]
One common set of plugins is Airbnb’s configuration so add those too:
Now put the following into .eslintrc.js (you’ll need to create this file):
module.exports = { 'extends': 'airbnb', 'parser': 'babel-eslint', 'env': { 'jest': true, }, 'rules': { 'no-use-before-define': 'off', 'react/jsx-filename-extension': 'off', 'react/prop-types': 'off', 'comma-dangle': 'off' }, 'globals': { "fetch": false } }
Now you just need to add the plugins to your editor. For Sublime there’s ESLint which gives you an output of errors (or issues) with CTRL + ALT + e (Cmd + Option + e on Mac). There also one for VSCode.
A lot of these errors can be fixed automatically using the eslint --fix command which you can run from your editor with the ESLint Fix package.
Add Styled Components for React Native
React and React Native build interfaces using web technologies, i.e. HTML, CSS, and JavaScript. One very popular library to use with React (and React Native) is Styled Components which clean up how one adds CSS to your components.
For example, take a look at the following code, taken from the React Native sample app (which is what you get with react-init):
export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <Text style={styles.welcome}>Welcome to React Native!</Text> <Text style={styles.instructions}>To get started, edit App.js</Text> <Text style={styles.instructions}>{instructions}</Text> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
You declare your DOM elements (View, Text), linking them to styles, and then create the stylesheet later.
With Styled Components you would do the following:
const Container = styled.View` flex: 1; justify-content: center; align-items: center; background-color: #F5FCFF; `; const Welcome = styled.Text` fontSize: 20; text-align: center; margin: 10; `; const Instructions = styled.Text` text-align: center; color: #333333; margin-bottom: 5; `; export default class App extends Component<Props> { render() { return ( <Container> <Welcome>Welcome to React Native!</Welcome> <Instructions>To get started, edit App.js</Instructions> </Container> ); } }
It’s both cleaner and more portable (CSS names don’t clash, etc.).
To install it, run npm install [email protected] from the root directory.
Add Custom Fonts to Your React Native App
To get a custom font like Racing Sans One into your application you first need to download the ttf and put it into assets/fonts (you will need to create this directory). Then add the following to your package.json:
"rnpm": { "assets": [ "./assets/fonts/" ] }
Finally run react-native link from the command line. You should now see your font inside of android/app/src/main/assets/fonts. You should be able to use it now. Create a components folder and put the following inside of components/Header.js:
import styled from 'styled-components/native'; export default styled.Text` color: black; font-family: RacingSansOne-Regular; font-size: 32px; margin-top: 120px; background-color: transparent; text-align: center; `;
Then, import this into your App.js and add <Heading>Welcome</Heading> above the Text nodes:
import Header from './components/Header'; ... export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <Header>Welcome</Header> <Text style={styles.welcome}>Welcome to React Native!</Text> <Text style={styles.instructions}>To get started, edit App.js</Text> <Text style={styles.instructions}>{instructions}</Text> </View> ); } }
And you should get a nicely formatted header:
Adjust Your App to be Fullscreen on Android
To get your app to not show the title bar, go to android/app/src/main/res/values/styled.xml and add the following inside the <styles> element:
<item name="android:windowFullscreen">true</item>
Now when you re-run you should see the navigation bar is gone.
Create the Android App Components
It can take a long time to decide on a final design, with layout, colors, and fonts. This is often an iterative process. Here you’ll go through how to build up the final result you saw at the start - which was inspired by related online tutorials and styling examples - but remember that it takes time to get to something you like.
Change App.js to the following:
import React from 'react'; import { Container, Header, Input, Keypad, ButtonRow } from './components'; const App = () => ( <Container> <Header>Prime Components</Header> <Input>123456</Input> <Keypad> <ButtonRow keys={['1','2','3']} /> <ButtonRow keys={['4','5','6']} /> <ButtonRow keys={['7','8','9']} /> <ButtonRow keys={['0','Clear','Go']} /> </Keypad> </Container> ); export default App;
You can see here how clean things are with Styled Components. We have a header, an input and a keypad (all names you choose) all surrounded by a container. No superfluous information. The styling happens in the components.
Create the components directory. Inside components/index.js put the following:
export { default as Input } from './Input'; export { default as Container } from './Container'; export { default as Header } from './Header'; export { default as Keypad } from './Keypad'; export { default as Button } from './Button'; export { default as ButtonRow } from './ButtonRow';
This is just a convenience module that allows for the importing as in App.js, i.e. ` import { Container, Header, Input, Keypad, ButtonRow } from ‘./components’;`. Otherwise, you’d have to import each component on a separate line.
Put this into components/Container.js: (Note: you must use capital letters for your components in React Native!)
import styled from 'styled-components/native'; export default Container = styled.View` flex: 1; `;
Very simple: you are extending a View component and assigning a flex value of one (which in this context means “take up everything”).
components/Header.js:
import styled from 'styled-components/native'; export default Header = styled.Text` flex: 1.5; font-size: 80px; font-family: Chathura-ExtraBold; background-color: rgb(29, 31, 33); color: gold; text-align: center; `;
Also, a styled text component, with large, centered fonts, a gold color, and grey background. Make sure you install the Chathura font from Google Fonts as before!
components/Input.js:
import styled from 'styled-components/native'; export default Input = styled.Text` flex: 2; text-align: right; font-family: Audiowide-Regular; text-align-vertical: center; font-size: 70; color: firebrick; background-color: gold; `;
Similar to before except now with the Audiowide-Regular font (also available from Google Fonts).
components/Keypad.js:
import styled from 'styled-components/native'; export default Keypad = styled.View` flex: 6; background-color: rgb(29, 31, 33); padding-top: 10px; padding-bottom: 10px; `;
Also just a styled view (essentially a container like a <div> in HTML).
components/ButtonRow.js:
import React from 'react'; import styled from 'styled-components/native'; import { Button } from '.'; const RowBox = styled.View` flex: 1; flex-direction: row; `; export default ButtonRow = ({keys}) => ( <RowBox> { /* https://stackoverflow.com/a/32157488 */ } {keys.map(key => ( <Button text={key} key={key} /> ))} </RowBox> );
Here, things get complicated. You are importing a Button from the current directory (which you’ll create in a second), creating a component called RowBox which is not exported, and then ButtonRow is defined having a React property called keys.
Then you are mapping each key to a button component. This is a clean way of looping through an array as with for each and using the value to set both the text and key attributes (you must set a key attribute to make the DOM object unique!). You’ll be using the text to render the button.
components/Button.js:
import React from 'react'; import styled from 'styled-components/native'; /* https://kylewbanks.com/blog/react-native-tutorial-part-2-designing-a-calculator */ /* https://github.com/styled-components/styled-components/issues/149 */ const ButtonBox = styled.TouchableHighlight.attrs({ underlayColor: '#193441', })` flex: 1; align-items: center; justify-content: center; background-color: rgb(39, 41, 43); border-radius: 10px; margin: 5px; `; const ButtonText = styled.Text` font-size: 30; font-family: Orbitron-Bold; color: ${props => props.text=="Go" ? "green" : "orange"}; `; handleButtonPress = (value) => { }; export default Button = ({text}) => ( <ButtonBox onPress={() => handleButtonPress()}> <ButtonText text={text}>{text}</ButtonText> </ButtonBox> );
This is the last component. You start by creating a ButtonBox which just acts as a container over the whole button. It is using TouchableHighlight which is a React Native component that will change color when touched. The styling is normal except for the underlay color (the color you see when touching) since this needs to be hacked to work in Styled Components.
The post Develop an Android App with React Native & Publish on Google Play appeared first on SitePoint.
by Karl Penzhorn via SitePoint http://bit.ly/2Hs4z54
0 notes
Text
SDKMAN! Managing SDKs Was Never so Easy
#ICYDK: If you’re working on multiple Java projects, it is very common to switch between different Java versions. I face this too often. We have a number of projects running in production that need a different Java version. Sometimes, we need to fix issues or to add a customer required feature in older projects. These older projects require Java version 6 or 7, while newer projects require Java 8 or 9. So, it is often required to switch between them during development. There are many different ways to switch between Java versions, and most of them are dependent on different OS environments i.e. MacOS, Linux, Windows, etc. Below are some examples of how to do the switching. https://goo.gl/Z7bGkV
0 notes
Text
[GUIDE] SWITCH FROM ONE VERSION OF JAVA TO ANOTHER WITH SDKMAN
[GUIDE] SWITCH FROM ONE VERSION OF JAVA TO ANOTHER WITH SDKMAN
SDKMAN! is a tool that allows you to manage multiple versions of various dev kits on Linux but also on macOS, Solaris and FreeBSD. There are tons of dev kits that you can configure: Java, Groovy, Scala, Kotlin, Ceylon, Ant, Gradle, and many more. SKDMAN! It is written in Bash (but also works with Zsh) and only requires curl and zip / unzip to work properly. In this article, we see how to install…
View On WordPress
0 notes
Text
Using SDKMAN To Manage Java Versions
http://dlvr.it/QxmGVV
0 notes