Need help building a Selenium Java Class file from cmd line - java

I'm trying to cmd line compile a .java selenium test script into a class file that I can run from the command line.
All of my selenium jar files and all other supporting jar and lib files are in C:\JarFiles
My CLASSPATH is set to C:\WDJarFiles*
I am working at the command line here: C:\EclipseIDEworkspace\MC3\src\Tasks
My .class files are located here C:\EclipseIDEworkspace\MC3\bin\Tasks and I'd like to be able to update them at that location.
My folder structure was set up by using Eclipse IDE so I'd like to keep the existing folder structure but now I want to be able to compile my .java files from the command line and update the .class files.
So, when I run javac like this:
javac Edit.java
It compiles OK and the .class file gets created in the same folder where I am running the javac command -- but -- I also get a huge number of other .class files in this same directory! These look like supporting class files.
I'm not sure what my cmd line javac syntax should be to:
Compile my .java file so its .class file gets updated in the C:\EclipseIDEworkspace\MC3\bin\Tasks folder.
I don't get all those other .class files created in my working folder C:\EclipseIDEworkspace\MC3\src\Tasks
Thanks for any help...

You should try the '-d' option to specify an output directory:
javac Edit.java -d ..\..\bin\Tasks
About the multiple other .class files, you probably have many nested classes into your Edit.java file?

Related

How to add .jar files to javac compilation (Windows 10)

I am tryin to compile my java classes like this at the moment with javac
javac myClass.java
I am also using some .jar files (poi-3.15.jar...), which are necessary for classes such as Row, HSSFSheet and so on (for getting information from excel).
If I loaded these .jar files into Eclipse, I had no problem getting things working.
However, using the command prompt, my .jar files are not found.
I've put my .java files in the /src folder and .jar files to where my .classpath is. The compilation doesn't work.
Is it possible to place .java and .jar files into the same folder, successfully execute "javac" command and then execute the program.
I need to send my homework to a teacher, so the only thing he has to do is run the "javac myClass.java", following with "java myClass".
Any help is much appreciated!
To include jars, use:
javac -classpath "/path/to/jar1.jar;/parh/to/jar2.jar" MyClass.java
This will add jars to your classpath at compile time.

how to use JDatePicker jar file into the program

I need to use 'JDatePicker' class for a program. I downloaded 'jdatepicker-1.3.2.jar' file. and when i extracted the file using the command "jar xf jdatepicker-1.3.2.jar", I got 3 folders in the directory " META-INF, tutorial, net". But i don't know how to import this to the java program and where to store this jar file and the extracted folders. could any one assist me on the above?
I don't use any IDE. I run the java programs in command prompt
You must have that exact jar file on the class path. When compiling specify jar in the compile
javac -classpath jars\jdatepicker-1.3.2.jar -sourcepath src\project -d classes src\project\MyProg.java

Export generated class files and resources equivalent command line command

I'am working on a python script , which involves few steps of creating a jar file.
However when i run the following lines of code i get the jar file created, having .java files and not .class files .
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/src'])
Is there any way to get the jar file created with .class files similar to Export generated class files and resources checkbox in export jar dialog in eclipse .
Thanks
Make sure where is your *.class files located, I assume it is in bin directory or something:
subprocess.call(['jar', 'cvf', 'process.jar','C:/my data/temp/process/bin'])

Include a jar archive without including in environment variables

I want to include org.eclipse.swt.3-1.jar in a .java file without put it in my environment variables? How can I do this?
The java src I want to try is this.
I have just this file as a .java file and I have from here http://www.java2s.com/Code/Jar/o/Downloadorgeclipseswt31jar.htm the org.eclipse file. Both in the same directory.
PS: I compile on the command line and don't use Eclipse.
its just 2 files, the .jar and a .java - both in the same directory
Then you need to first compile the java source (.java) file into a class file (.class) file. You use the javac command from the JDK and something like
javac -cp org.eclipse.swt.3-1.jar;. file.java
Then your directory should contain 3 files, te .jar and .java and a .class file. Then
java -cp org.eclipse.swt.3-1.jar;. file

changing code in Java class file with dependencies

I started off with a .jar file that I unzipped. I need to change a few lines of code in just ONE of the classes contained in the contents of that jar file. I went about this as follows:
1) opened the class in Java Decompiler to view the source.
2) copied source to a new text file and saved with ".java" extension.
3) in command line I went to jdk folder and executed javac Classname.java to recompile.
However this class code imports some dependencies so the recompile failed. I have the dependencies, they were part of the original jar file contents but they are all compiled .class files and spread across several folders...
Is it possible to re-compile this class successfully? Is there command line code to include dependencies?
Yes, use the -classpath option.
javac -classpath original.jar Modified.java
Then, you can remove the old class from the jar file and insert the new one. There isn't a simple way to do this via command line, so I recommend an archive application such as WinRAR or 7-zip.

Categories

Resources