Search This Blog

Saturday, September 26, 2015

Gradle , how to start ?



Download Gradle
https://gradle.org/gradle-download/




Configure environment entries
add GRADLE_HOME/bin --> path ,where GRADLE_HOME is gradle installation folder.


Reboot


Check by typing gradle -v to see if it installed correctly


Now create an eclipse project with source attached below






package main.java.hello;



public class Greeter {

public String sayHello() {

return "Hello world!";


}

}




////


package main.java.hello;

public class HelloWorld {

public static void main(String[] args) {

Greeter greeter = new Greeter();

System.out.println(greeter.sayHello());




}


}


//////////////


Once done make a file called build.gradle in root folder of your project.




content of build.gradle

apply plugin: 'java'











go to command prompt and rungradle build





Gradle working fine on your system




how to troubleshoot ssh on ubuntu if putty is not connecting

apt-get install openssh-server

Check if sshd_config is available /etc/ssh/sshd_config

If available, please check if the port is not commented out.

sudo restart ssh

If you get the error, "Unable to connect to Upstart", restart ssh with the following:

sudo systemctl restart ssh
If you are still not able to connect enable it in firewall
 

Friday, September 11, 2015

How to do Mac to IP binding in router

Some times when you are doing port forwarding on router, it becomes important that you bind the mac address of the device to the IP inside the router configuration.


To do this navigate to


Setup-->localnetwork









Add your mac address +fixed IP address +reboot the router.


Your device will always acquire the same IP on the LAN and you can use port forwarding to forward your services.

Read properties File from a WAR module running on Eclipse

I came across a problem where I was able to read property file for a Java project but when it was being deployed to tomcat as a war it was giving problem.

 
The code that worked is pasted below

 
  1. Create a src folder and name it resources
  2. Put the property file there.
  3. In the code access it like this

 

 
 InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("db.txt");




If you are making it for a DBconnection class which you are using for DAO in your code. The DBconnection  class will be static.

Get a free static IP for your computer

If  your laptop has a dynamic IP you won't be able to access it over internet or a shared LAN, because its address will change every time it boots up.
 
 
To solve this
 
  1. Get a free IP from noip.com
  2. Download their client.
  3. Now your IP will not change even after you reboot the computer.
Now since you are having a static IP you can do port forwarding and host number of services on your system like Apache or Cloud based services.


To know about port forwarding click here

Saturday, September 5, 2015

Find JAVA_HOME value from Command prompt

echo  %JAVA_HOME%

How to Check Java Version ?

Go to command prompt and run


java -version


You will get java version, if it ends in error saying.
 "java is not recognized as an external or internal command"


Add path to JDK/jre to the path variables in the (My computer -- > advanced settings)


Reboot and try again.


This time you will get JDK version.