[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

How to run an eclipse project class from the console without moving referenced filesw in the eclipse project root?

Hi Im trying to run a class made in an eclipse project from the console. I learned that the classpath has to be set to the bin dir of the eclipse project in order for the app to run. However Im doing a ssl client server app where I have to refer to a keystore file from the server that is located in the eclipse root directory (that is the parent dir of the bin folder) and can't make it work. If I move the keystore fil to the bin folder it runs without any problems by this (so this works):

java -classpath D:\Projects\Eclipse\MyProject\bin -Djavax.net.ssl.trustStore=serverks -Djavax.net.ssl.trustStorePassword=123456 server.control.ServerApp

I tried referencing the keystore file directly with a path instead of just using the name, which doesnt work:

java -classpath D:\Projects\Eclipse\MyProject\bin -Djavax.net.ssl.trustStore=D:\Projects\Eclipse\MyProject\serverks -Djavax.net.ssl.trustStorePassword=123456 server.control.ServerApp

How can I run it without moving the keystore file?
0
Suppai
Asked:
Suppai
  • 3
  • 3
  • 2
2 Solutions
 
objectsCommented:
easiest is to first build a jar from your project and add that to your class path (plus any other required jars)

0
 
objectsCommented:
not sure why its not finding it. if you don't specify the pat hit should look in the directory you run it from

0
 
CEHJCommented:
You might try the following:
-Djavax.net.ssl.trustStore=D:/Projects/Eclipse/MyProject/serverks

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SuppaiAuthor Commented:
But if I just want to run it without making jars and such? I mean it works fine as long as I just move the file, I must be able to refer to it as being in another location I would think? What Im trying to obtain is to view the server processing output as the server (that doesnt have a gui) reacts to the inputs from the client, which works if I move the file, but I would rather that they just refered to the same file, and when running the server in eclipse it automatically refers to file in the root of the eclipse project root, so thats no problem, its just different when running from the console.

Btw is there a way to bring up separate consoles for each run in eclipse, because then I could get around this problem without using the windows command line.
0
 
objectsCommented:
yes, java works with / path seperator regardless of what OS you run in so its best to use it where possible.

0
 
CEHJCommented:
Not exactly sure what you mean by the above, but if the path is correct then you should be able to 'refer to it as being in another location', yes
0
 
SuppaiAuthor Commented:
Ahh ok. However I found out how to use separate consoles in eclipse and pin them for each app, which makes it much easier. Thanks for your help.
0
 
CEHJCommented:
?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now