Durand Grimmett

Greenhorn
+ Follow
since Jun 02, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Durand Grimmett

Sorry you guys....I jumped the gun, I just figured it out.....FileChooser.getSelectedFile().getName();

Thanks anyway,

DG
18 years ago
Hello all,

Im using a File Chooser to allow users to select a directory and to name a particular jar file. However, I want to capture the name of the jarfile that they input into the textField within a string variable. Right now if I do a textFieldName.getText(); .........it will return me the entire path to the jar file. I just want the name of the jar file. I considered using the subString method, but this wouldn't be efficient in my case because the length of the path and the name of the file will most likely be different in each case. I was wondering if anyone has any suggestions in this matter? I also noticed that the FileChooser Class does contain a getName method, but this didn't work for me either. Any suggestions?

Thanks in advance,

DG
18 years ago
Hello all,

I am trying to extend my .xsd file by utilizing the Extension Feature, but im not using the command line, im writing an application that mimics the procedure that is usually carried out on the command line. I have the instructions for using the Extension feature from the command line:

1. Place an XML comment around the extension element in the .xsdconfig file. Then at a prompt in the working directory perfom the scomp command

2. Compile the interface and handler class using the resulting jar from step #1 and xbean.jar

3. Remove the XML comment around the extension element in the .xsdconfig file. Then run scomp again with the .xsd and .xsdconfig Files, making sure that compiled extension classes from step#2 are on the classpath.

My application performs all of the previous steps however, when i run the scomp command for the second time(Step #3), I get the error "Build Failed". Which classpath should I be setting? System.setProperty()? or SchemaCompilerParameter.setClasspath()? Also within the SchemaCompilerParameter class there is a setBaseDir() method, should I set this as well, and if so what do I set it to?..........Im pretty sure that this is a configuration issue because I can make it work from the command line. Can anyone help me Please???

P.S. There is also a SchemaCompilerParameter.setExtension() method......does anyone know what this does or how to use it?.....the javaDocs on this package are not too good, there are no explanations.

Thanks in advance,

DG
your quote and my previous post are saying the same thing....which brings me back to the question....What's the benefit of me changing the extension of my source code?......My source code files need the extension .java so that it can be compiled correctly, it doesn't make sense, to change the extension to .class if im actually referring to java source code. All i want to do is gain access to the .class files that are produced after compilation so that I may jar them. This why I was asking if you had any input on searching a directory for .class files and storing them in an Array, then I can pass that array to my Jar method.
18 years ago
sorry Joe, you're right patience is a virtue!....Im glad you pointed me to that page because I've never read it before. Now that I've been schooled on the proper way to make posts on this site, I will follow the guidelines. Thanks again for your help.

Ok, back to the issue at hand. I don't know if changing the file extension will work for me. I am compiling .java files, and as you know, in return i get .class files. Even if I change the .java extension to .class , is it legal to name my source code xyz.class when its not actually byte code? Or will the compiler still convert my source code to byte code? If so, does it just overwrite the contents of my source code with the byte code, keeping the same name?
18 years ago
Since no one replied to my other post...I may have come up with a work around, but i still need some assistance.

Does anyone have any sample code, or can anyone point me to any sample code that will search a directory?......Specifically, I need to search a directory for .class files and store those files in a String array.

Thanks in Advance,
DG
18 years ago
Hello all,
Right now the code that I have posted below will compile the two .java files provided....and it will also jar these files...But I want to jar the resulting .class files that get generated after the compilation....

However, the compile method doesn't return any files, it returns a boolean that indicates whether the compile was successful or unsuccessful. After a successful compilation The .class files are placed inside my working directory. As the code works now, it jars the .java files because those are the files that i past it. Can anyone help me to figure out how to jar the .class files that result from the compile?


//This method allows the user to name the jar file and choose the files to jar

private File interfaceFile;
private File handlerFile;

public void compileAndJar()
{
System.out.println("Entering the compileANdJar() Method....");

// These are the files to include in the Jar file
String[] filenames = new String[]{interfaceFile.getName(), handlerFile.getName()};
System.out.println("INTERFACE FILE NAME----> "+interfaceFile.getName()+" HANDLER FILE NAME----> "+handlerFile.getName());

//compile the interface and handler files
try
{
sun.tools.javac.Main comp = new sun.tools.javac.Main(System.out, null);
boolean iFacesuccess = comp.compile(filenames);
System.out.println(comp.compilationPerformedSuccessfully());
}
catch(Exception e)
{
e.printStackTrace();
}

// Create a buffer for reading the files
byte[] buf = new byte[1024];

try
{
// Create the jar file
String outFilename = jarTextField1.getText(); //Allow the user to set this variable
System.out.println("JAR FILE NAME----> "+outFilename);

JarOutputStream out = new JarOutputStream(new FileOutputStream(outFilename));

// Compress the files
for (int i=0; i<filenames.length; i++)
{
FileInputStream in = new FileInputStream(filenames[i]);

// Add JAR entry to output stream.
out.putNextEntry(new JarEntry(filenames[i]));

// Transfer bytes from the file to the JAR file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}

// Complete the entry
out.closeEntry();
in.close();
}

// Complete the JAR file
out.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
[ June 15, 2005: Message edited by: Durand Grimmett ]
18 years ago
Question...is it possible to invoke an ant task within a java program? If so how?

next....does anyone have an example of an ant task that compiles java files..........or compiles and jars java files?
--------------------------------------------------------------------------------
18 years ago
Question...is it possible to invoke an ant task within a java program? If so how?

next....does anyone have an example of an ant task that compiles java files..........or compiles and jars java files?
18 years ago
The thread that you pointed me to does contain some useful info....but do you have any other examples or sample code that you can refer me too.
I actually just looking for a simple method that I can use, that takes some .java files and compiles them to .class files

Thanks in advance for your help
18 years ago
I don't understand how your expected o/p was "bye bye bye"

intially the value of 'ad' is "hi"
then you assign ac=ad.......which makes ac=="hi"
finally you assign ad="bye"

so at the time of your system.out.println.......ad=="bye" and ac=="hi"
which is why you get the output of "bye, hi, bye"

if you wanted the output of "bye, bye, bye"
after the statement ad="bye"
should be the statement ac=ad........then your system.out.println()

i hope this helps

DG
18 years ago
Does anyone have any sample code that will take some java files and compile them programmatically.....that is without using the command prompt?....Any help will be greatly appreciated.
18 years ago
Hello all ,

I was wondering if anyone could provide me with some help. I want to create a jar file programmatically. I know how to use the command line to create jar files, but i was wondering if anyone had a java program that read a directory and created a .jar File? Can anyone help please???!?!?!?

Thanks in advance,
DG
18 years ago
hello,
Does anyone know how to implement a jedit plugin(xml plugin) into an existing java application that was created in Jbuilder. I just downloaded jedit to make use of its xml text editor capability, but im having a tough time trying to bring it together with my existing app. Can anyone help with some steps to accomplish this task.

Thanks,
DG
19 years ago
Does anyone have the steps to configure log4j with a plain text config file?i.e....an example config file, and/or which directory to place my log4j.properties file in so that it will be read properly. Im having major issues with getting started logging, any help will be greatly appreciated...
[ June 15, 2004: Message edited by: Durand Grimmett ]
19 years ago