I have to code some classes that are accessed from a program. The problem is, I don’t have the source of the program, I only have the API that I have to comply with.
Now, I have the compiled class files in a jar and I can execute the program with my code from the command line with “java -cp prog.jar pkg.mainClass args”, but I cannot select the main class in netbeans in order to be able to quickly test my code.
Does anyone know whether it is possible to specify a main class that’s inside a jar?
From what I see, you’ve got a jar file with no source and classes inside make up an API. Nothing new.
But I’m scratching my head when I read this part:
“Now, I have the compiled class files in a jar and I can execute the program with my code from the command line with “java -cp prog.jar pkg.mainClass args”, but I cannot select the main class in netbeans in order to be able to quickly test my code.”
From that paragraph, it seems that the main class is inside that jar file. Also, you want to be able to quickly test your code. Do you mean that you’re changing that source, even though you haven’t got it? Or do you want do debug it? Or unit test it? This part seems a bit unclear.
Your situation seems pretty confusing, so I can’t suggest anything else than just to make a new main class in Netbeans, import everything from that jar file and just use it’s API.