Problem while trying to execute ant file in java - eclipse

I'm trying to compile a service using a java ant file as appears below:
and my buid-jar.xml looks like this:
the problem i have is that eclipse is not recognizing the enviroment variables and it takes the names literally causing an error on building time:
Both, paths and ant files does exists in these routes in my user folder, but i don't know why this error is happening. I'm using jdk 1.8.0_45.
Any idea? Sorry i had to attach screenshots instead code, but the proxy of the company network that i work for doesn't allow me to navigate on stackoverflow.

Related

provide wrong classpath for netbeans [duplicate]

I need to make a GUI Application for my class , so I want to make sure I can transfer a netbeans project using the GUI Builder (I know how to make it without it, but that's more time consuming and I think it would look neater without me guessing coordinates etc. and I was use to the netbeans GUI builder) from netbeans onto unix and compile it. So here's what I did I made a new JFrame form (using netbeans GUI Builder) called StartFrame.java and another called MenuFrame.java. (keep in mind that it ran with no errors in netbeans) StartFrame creates a new instance of MenuFrame and opens it on it's first run. So I transferred all of it onto the unix system. So at first I tried compiling it, but of course it got errors, saying that org.jdesktop... isn't found.
Okay so I've already searched stackoverflow and the web for this. So I ended up getting the swing-layout-1.0.4.jar from the libraries in netbeans.
I'm kind of new at compiling from command line, but I put them all in the same folder, and while I was in that directory.
I did
javac StartFrame.java -cp swing-layout-1.0.4.jar
and I got the error that NoClassDefFoundException: MenuFrame even though it is in the same folder. So then I tried
javac StartFrame.java MenuFrame.java -cp swing-layout-1.0.4.jar
and it compiled fine with no errors. So then It created 6 files StartFrame.class StartFrame$1.class StartFrame$2.class StartFrame$3.class StartFrame$4.class MenuFrame.class
I tried running it with
java -cp swing-layout-1.0.4.jar StartFrame
and it had a NoClassDefFoundException: StartFrame. I searched the web for fixes for this and stack overflow and found similar (not exact though) problems like this, but none of those fixed it.
The file dist/README.TXT will tell you how to proceed. Type ant -p at the command line to see that available commands: ant run is usually good.
Addendum:
The machine doesn't have ant installed
That would be unusual, so you should certainly verify it. You may need to add the current directory to the path, e.g.
java -cp .:swing-layout-1.0.4.jar StartFrame

Testng - Ant - windows terminal how to deal with errant input

I have a java selenium QA project where we use ant and testng via the powershell terminal. What I would like help with is creating a redirect if a tester enters a typo in the terminal.
If I am in the run directory and I simply type ant, it will run the default.xml file listed in the build.xml file which is what I expect.
If I enter an actual ant command with a typo though:
ant -Dtestdir= c:\dev\qa\src\tests -Dtestxml=blablabla
it will attempt to run every test.xml file in the test directory. This is especially problematic because most of the those test.xml files call java classes that contain #Factory and #Dataprovider(s) and they allocate everything at once which just causes everything to fail.
What I would like is a way to tell ant if the input is erroneous, then run the default.xml file(which I have configured to populate an html error page). I've been reviewing both testng and ant docs and I'm not finding a solution, so your guidance would be appreciated.
Other than this one issue, the system works very well.
After digging around a bit more and learning how to ask the question properly, I found 2 great examples here on SO.
1) Create an additional ant target that checks for the existence of the file the user has typed. And add it to the depends attribute of the main target , and also adding the if attribute.
Example
2) Use the Ant fail task and fail the build (with a message) if the file is not available. I prefer this one because the tester can get some feedback.
Example 2

deploying a scala app built using IDEA

I developed a simple scala app that uses casbah to query the DB for the command line argument passed to it. For example
$ querydb.scala execution 10
it will run a casbah query to find 10 records matching execution in mongo. Now i have two questions.
1) How do i test this in my local. If i click execute in intellij it is just running the program, i am not able to pass command line arguments to my program.
2) How do i deploy it to run on my server, it is just going to used as console app in my ubuntu server, but im not sure how i should deploy this, which files i should put up on the server and how do i execute it in server, and stuff like that.
Any pointers would be useful for me.
or try to use sbt, IDEA has a plugin with sbt, the wiki of it has an explanation on how to use it.
I usually use sbt directly in Terminal instead of running in IDE.
1) First you need to find "Select Run/Debug Configuration" button at the top of your screen
Click on it and choose edit
Create new one, if you haven't got it yet.
Your program parameters should be written in "Program parameters" field
2) Compile your .scala files with scalac and you'll got .class files.
Then deploy it, as you usually do with java code. Hence you don't need to install scala on target machine - all you need is JDK.

How can I in ant wait until a file is usable?

I'm trying to fix a build file where a part of it runs a bash script to generate a file. This file generation takes under a second and wasn't a problem until we moved to eclipse.
The issue is that if I save any file in eclipse with a change and then run ant to build. I get a "class not found" error on the generated file. Seems like eclipse is doing something to the newly generated file (it even shows it with an error check box)
If I wait a few seconds more and run the build again, it works fine.
What I have been trying to use is this.
<waitfor maxwait="30" maxwaitunit="second">
<available file="${src}/thefile.java"/>
</waitfor>
It does not work. I also tried to look at something called <readable> under the selectors set which by the documentation could be used in junction with some other waitfor methods.
How can I fix this problem or is there another way around it?
Found the issue. Eclipse was locking the generated file while it was building the workspace so the bash script that generated it would mess up.
The building of the workspace took 4-5 seconds so that was the delay.
I was able to speed up the building of the workspace by disabling the XML and DTD validation. (Window > Preferences > Validation)

Workspace is closed error

I have created a EMF model and generated a model code for that. I have created one plugin project and i have created one class named as 'CommandTest' which is having "public static void main()" method which reads mymodel resource file.
Its working fine in eclipse 3.5.2. There is no issues am able to read the contents.
But same thing am running through command prompt, am getting error "Workspace is closed". I have included my plugin folder in my classpath.
I have used one statement resource.load(null). In this line am getting "IllegalStateException: Workspace is closed".
I want to run my project in commandline not in eclipse environment. I have searched this problem in internet, i can able to find some solutions but its all related to eclipse environment.
If anything am doing wrong in this following statement
====Code Snippet======
file = "C:\temp\mytemp.xml";
// Creating resource
XMLResource resource = (XMLResource) new MyModelResourceFactoryImpl().createResource(
URI.createURI(file.toURI().toString(), true));
resource.load(null);
=======================
Is it possible to run plugin project in commandline? if it is possible could any one guide me how to achieve this to avoid "workspace is closed" error?
Did you try to specify a workspace with the -data <workspace-path> command line switch? You could try as well to call Plugin.getStateLocation().