I have two Play framework web applications running on my system on ports 9001 and 9002. I was wondering if there was any way I could retrieve which port they were running on from within my Java code.
Is this possible?
Yes. You can get the port like this:
int port = Integer.parseInt(Play.configuration.getProperty("http.port", 9000));
Of course, you have to import the class play.Play.
In Play 2.4.x:
Play.application().configuration().getString("http.port");
or simply:
System.getProperty("http.port");
This only works in production mode, when the http.port is set via the Java -D parameter.
Since the system does not let me comment yet, I'm forced to add my comment here.
The given answer by Carsten must be for play1, for play2 see Retrieving port number in Play Framework 2 app
Related
I have an entry in my .ssh/config file that looks like:
Host ip-172-16-*
ProxyCommand ssh jeff#jumpdev.example.org nc %h %p
User ubuntu
IdentityFile ~/.ssh/id_rsa_aws
StrictHostKeyChecking no
ForwardAgent yes
As most know this will allow me to run:
ssh ip-172-16-2-108.ec2.internal and I drop onto the private server, as the default user for Ubuntu EC2 instances - ubuntu. I'm looking to take some specific actions on create.
Ultimately what i am looking for is the same functionality with either scala-ssh, jassh or directly from jsch
I'm not asking for anyone to suggest a library, just how/if this functionality is supported. With jassh, i've attempted with the Proxy options with no luck.
Ultimately i could shell out directly to ssh, but even with ammonite, it won't load the config if using %('ssh, Symbol("ip-172-16-2-108.ec2.internal"). I thought that would use the base ssh, which would load the config and match, like bare ssh. I could also set up my config not to use nc
This does sound like i'm asking for a library, so if it gets closed, so be it, but i've tried 4 directly and none, seem to completely support .ssh/config
TIA,
Jeff
I know there are other answers, but I found that by switching from ProxyCommand to ProxyJump in my .ssh/config allowed ammonite to work perfectly. Also since all I need is a solution to this problem and am already using ammonite, it is a good match.
If others have other experiences, I think this is a good question to leave open, as we're talking about specific libraries which are all built off Jcsh.
FWIW, my .ssh/config now looks like:
Host ip-172-16-*
ProxyJump jeff#jumpdev.example.org
User ubuntu
IdentityFile ~/.ssh/id_rsa_aws
StrictHostKeyChecking no
ForwardAgent yes
Hope this helps someone.
I want to write 2 Device Communication Servers for use with OpenGTS (Enterprise). Devices are Teltonika FM4200 and WirlessLinks Piccolo STX. can u give me a some tutorial or something useful. I still don't have idea on it.
Instead of DCS you can use Traccar server which already supports FM4200, the second device might already be supported as well, I just need some message examples to verify that. Configuration file to integrate two systems can be found here.
I need to run a java application (not an applet or JNLP, but a full blown application in the JRE) and need some restrictions on:
File System - The app could only access 1 folder to read & write (this would be a fixed path for the app's reference like / )
Ports - The app could only access several local ports. (eg could only access port 8080 / 3306 only)
Is there a way to do this? I have searched through Java Security & Policies but came nothing close to a solution.
I am considering to write a container to run this app or changing / overriding the classes (in case of OpenJDK). Is this ok?
This is for an open source project that we are about to start, Appreciate some good advice from the wise StackExchange community.
regards
First and most basic, run the java application with a user who has the minimum permissions required for the app to do its work.
Secondly, set the java SecurityManager and configure it.
SJuan76 has the right answer here. The SecurityManager is the appropriate way to restrict files/directories a java app can access. This tutorial might be a good guide to setting that up.
You can restrict the ports your java app listens on. But restricting ports really requires an OS level firewall to be configured.
I am looking to create Multi-agent systems based focused crawling. I have seen different mobile framworks such as Aglet, JADE, etc,. My work is want to create a number of agent at resident Local host and want to move it with parameter to resident Remote host. My question are, which framwork should I used to create agent? and how to create agent and migrate it to remote host via middle agent. please give me some example code how to create agent and migrate it. Thank you.
Take a look at Mobility-RPC, there are examples to do this on the front page.
I am learning Java and am trying to do some experiments with networking Java programs.
I have a program made in 2 parts with a client and a server and it works in local testing but the program actually has usefulness for me and a friend of mine and I want to put the server online so both of us can connect to it and use it.
Where/How can I put the program online and have it running so that the client programs can connect to the ServerSocket with an ip address? (Preferably free)
If you dont want to pay server hosting then I would open a virtual server on my computer, then playaround with modem and forward related port to server ip. I would use a port more than 40000. Then just send your ip and port your friend or update application.
If you really want the application to go live within 5 mins, try Jelastic. If you have built a WAR file, simply sign up with their server,choose a provider closest to your geo location, configure Tomcat and you can upload the WAR file through their fantastic web console. Otherwise if you have some source control system(SVN,GIT etc), you just connect and build it with their Maven console and you can be ready. I used it for my start up(Cloudlabz) and really found it exciting.
Surya
You could also consider the cheapest Rackspace Cloud Server. You'll get a full fledged Linux server (distribution of your choice) for about USD 11/month. I've done that now and then myself to try things out.
Just install Java on it and you're good to go.
http://www.rackspace.com/cloud/cloud_hosting_products/servers/pricing/
http://ideone.com/
is that what you want for this?
This is a free web app for you to run your program online....so you can just paste your code and run it.
On the cloud you could use two different services in order to host your Java application.
IaaS (Infrastructure as a Service). Where you can just rent a specific infrastructure on the cloud and you could install and configure all the services that you need.
PaaS (Platform as a Service). In this case, you still enjoy the infrastructure on the cloud + the service Aaren full pre-configured. It means that you can deploy your application without installing or configuring anything. You just need to deploy your application. You have an example about how it works here. Also, you usually can test your Java apps on the cloud without paying.
You should host the server in Heroku ,they offer a free hosting with limits , I have an app there